![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | 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 Specs![]() |
| | #2 (permalink) |
| Guest | Re: Process count wrong when only one process matches criteria It's the way PowerShell handles, or mishandles, scalar objects. Wrap the get-process statement in array notation '@()': $abc | % { ([wmiClass]"\\localhost\ROOT\CIMV2:win32_process").Create("xyz"); while (@(get-process xyz).count -gt 0 {start-sleep 60} } -- Kiron |
My System Specs![]() |
| | #3 (permalink) | ||||||||||||
| Guest | Re: Process count wrong when only one process matches criteria Thank you that got it. "Kiron" wrote:
| ||||||||||||
My System Specs![]() | |||||||||||||
| | #4 (permalink) | ||||||||||||
| Guest | Re: Process count wrong when only one process matches criteria "malverson26" <malverson26@xxxxxx> wrote in message news:4F55A117-5C0D-4FCB-8D9E-2F52A650D6AE@xxxxxx
(no output). I wrote a blog post on this subject you might find useful: http://keithhill.spaces.live.com/blo...3A97!816.entry -- Keith | ||||||||||||
My System Specs![]() | |||||||||||||
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get-process & stop-process by owner | Andrew Conrad | PowerShell | 3 | 03-03-2007 04:11 PM |
| File count wrong........... | =?Utf-8?B?V2Fyd2ljayBXZWJi?= | Vista file management | 0 | 09-29-2006 07:47 AM |
| Process dwm.exe | rarno | Vista installation & setup | 0 | 06-23-2006 08:37 AM |
| Process dwm.exe | rarno | Vista installation & setup | 0 | 06-23-2006 08:36 AM |
| Bug? Shouldn't Stop-Process automatically match Id if object is a process? | Alex K. Angelopoulos [MVP] | PowerShell | 3 | 06-21-2006 05:35 AM |