![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| | |||||||
| | Vista - Process count wrong when only one process matches criteria |
| |
| 10-05-2007 | #1 |
| | 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 |
| 10-05-2007 | #2 |
| | 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 |
| 10-05-2007 | #3 |
| | Re: Process count wrong when only one process matches criteria Thank you that got it. "Kiron" wrote: Quote: > 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 |
| 10-06-2007 | #4 |
| | Re: Process count wrong when only one process matches criteria "malverson26" <malverson26@xxxxxx> wrote in message news:4F55A117-5C0D-4FCB-8D9E-2F52A650D6AE@xxxxxx Quote: > Thank you that got it. > (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 | |
| |
| Similar Threads for: Process count wrong when only one process matches criteria | ||||
| Thread | Forum | |||
| Failover Guest Cluster -- 'The process cannot access the file becauseit is being used by another process.' | Virtual Server | |||
| Process Handle Count Charting | PowerShell | |||
| get-process & stop-process by owner | PowerShell | |||
| File count wrong........... | Vista file management | |||
| Bug? Shouldn't Stop-Process automatically match Id if object is a process? | PowerShell | |||