Techtip: One-liner to get free space

Say you’d like to copy an exuberant amount of data from one server to another and you’re unsure if the target disk has sufficient space. Perhaps you’d simply like to know how much space you’ve got.  There are several way to check this, but here’s one more, and in my opinion the fastest:

Run this one-liner from any computer, and as long as you run it a user context where you have user rights on the server, you will get the amount of free space in GB.

You can also use this a basis for a script listing out renaming space on several computers or several disks on a single server, but that might be the subject for another article!

Using Powershell to identify Child Processes

I got a challenge yesterday on how to identify child processes, and googling it led to the conclusion that this is either not a common issue or no one knows the answer.

My issue was this: if a child process locks up or needs to be killed, how do we identify the process using powershell. The thing about finding child processes is that you need to know who their parents are. In fact, you need to use the parent process id (PID) to identify the child.

How does it work?

First choose how to identify the parent process in Powershell. You can usually use ProcessName, Description, Path etc. Then you need to find any process which has the ParentProcessId of it’s parent (obviously)!

Here’s my solution:

$procid = (Get-WmiObject win32_process | where {$_.ProcessName -eq ‘Powershell.exe’} | select processid)
Get-WmiObject win32_process | where {$_.ParentProcessId -eq $id}

This only identifies the child process, what you’d like to do with it afterwards is your call. Nonetheless, this could help you automate some of the tasks you’ve been using Process Explorer to solve until now.