View Single Post
Old 10-05-2007   #1 (permalink)
malverson26


 
 

Process count wrong when only one process matches criteria

Trying to use get-process to determine when one job is finished to start
another one
$abc | % {
([wmiClass]"\\localhost\ROOT\CIMV2:win32_process").Create("xyz");
while ((get-process xyz).count -gt 0 {start-sleep 60}
}

However when there is only one process that matches the count property does
not return 1 and the comparison operators don't return the expected results.
See below for examples.

When two calc processes are running
PS C:\> (get-process calc).count -gt 0
True
PS C:\> (get-process calc).count
2
PS C:\>

When one calc proecess is running
PS C:\> (get-process calc).count -gt 0
False
PS C:\> (get-process calc).count
PS C:\>


My System SpecsSystem Spec