![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | filter out text.. In this I want to filter out "0 KB" (e.g Those apps whose WS has not changed in the specified $args [time])...but I am thinking my construct is not working with objects quite right. Any input is appreciated. $then = ps | %{$_ | Select Name, WorkingSet} sleep $args[0] $now = ps | %{$_ | Select Name, WorkingSet} $count = $now.count $difference = ( 0..$count | %{"WS diff is" + " " + $Now[$_].Name + " " + ( ( $then [$_].WorkingSet / 1KB ) - ( $Now[$_].WorkingSet / 1KB ) ) + " " + "KB"} ) $difference [output like:] ..\WS_diff.ps1 1200 ..... WS diff is explorer -12 KB WS diff is GoogleToolbarNotifier 0 KB WS diff is GoogleUpdate 0 KB WS diff is GoogleUpdaterService 0 KB WS diff is gpowershell 0 KB .... WS diff is powershell -16 KB |
My System Specs![]() |
| | #2 (permalink) |
| | RE: filter out text.. Try something like this $then = Get-Process | Select Name, WorkingSet #sleep $args[0] Start-Sleep -Seconds 5 $now = Get-Process | Select Name, WorkingSet for ($i=0; $i -lt $now.count; $i++){ ## check names if ($now[$i].Name -eq $then[$i].Name){ $diff = $now[$i].WorkingSet - $then[$i].WorkingSet if ($diff -gt 0){ "WS diff is {0} {1} KB" -f $($now[$i].Name), $($diff/1kb) Write-Host $now[$i].WorkingSet $then[$i].WorkingSet } } } -- Richard Siddaway All scripts are supplied "as is" and with no warranty PowerShell MVP Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "rferrisx" wrote: Quote: > In this I want to filter out "0 KB" (e.g Those apps whose WS has not > changed in the specified $args [time])...but I am thinking my > construct is not working with objects quite right. Any input is > appreciated. > > > $then = ps | %{$_ | Select Name, WorkingSet} > sleep $args[0] > $now = ps | %{$_ | Select Name, WorkingSet} > $count = $now.count > $difference = ( 0..$count | > %{"WS diff is" + " " + $Now[$_].Name + " " + ( ( $then > [$_].WorkingSet / 1KB ) - ( $Now[$_].WorkingSet / 1KB ) ) + " " + > "KB"} ) > $difference > > [output like:] > > ..\WS_diff.ps1 1200 > ..... > WS diff is explorer -12 KB > WS diff is GoogleToolbarNotifier 0 KB > WS diff is GoogleUpdate 0 KB > WS diff is GoogleUpdaterService 0 KB > WS diff is gpowershell 0 KB > .... > WS diff is powershell -16 KB > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: filter out text.. I would recommend that you capture the Id also. That way you are comparing the same process from run to run. Relying on the process name isn't very reliable. 120> $sb = { gps | Select Name, Id, WorkingSet } 121> $then = &$sb .... 123> $now = &$sb 124> $ht=@{}; $then | %{$ht[$_.Id]=$_} 133> $now | ? {$ht[$_.Id] -and $ht[$_.id].WorkingSet -ne $_.WorkingSet} | Select Name, @{n='Diff';e={$_.WorkingSet - $ht[$_.id].WorkingSet}} | Sort Diff -desc | % { "WS diff for $($_.Name) is $($_.Diff/1KB) KB"} WS diff for ipoint is 1784 KB WS diff for itype is 140 KB WS diff for dwm is 56 KB WS diff for msfwsvc is 12 KB WS diff for svchost is 12 KB WS diff for sqlservr is 12 KB WS diff for WmiPrvSE is 12 KB WS diff for msnmsgr is 12 KB WS diff for csrss is 12 KB WS diff for AcroRd32 is 4 KB WS diff for svchost is 4 KB WS diff for explorer is -4 KB WS diff for SearchIndexer is -4 KB WS diff for Moe is -8 KB WS diff for lsass is -12 KB WS diff for svchost is -12 KB WS diff for winss is -12 KB WS diff for wlmail is -72 KB WS diff for powershell is -1956 KB -- Keith "rferrisx" <rferris@xxxxxx> wrote in message news:dc972cd9-cd81-4112-9cf5-f93d03af1201@xxxxxx Quote: > In this I want to filter out "0 KB" (e.g Those apps whose WS has not > changed in the specified $args [time])...but I am thinking my > construct is not working with objects quite right. Any input is > appreciated. > > > $then = ps | %{$_ | Select Name, WorkingSet} > sleep $args[0] > $now = ps | %{$_ | Select Name, WorkingSet} > $count = $now.count > $difference = ( 0..$count | > %{"WS diff is" + " " + $Now[$_].Name + " " + ( ( $then > [$_].WorkingSet / 1KB ) - ( $Now[$_].WorkingSet / 1KB ) ) + " " + > "KB"} ) > $difference > > [output like:] > > .\WS_diff.ps1 1200 > .... > WS diff is explorer -12 KB > WS diff is GoogleToolbarNotifier 0 KB > WS diff is GoogleUpdate 0 KB > WS diff is GoogleUpdaterService 0 KB > WS diff is gpowershell 0 KB > ... > WS diff is powershell -16 KB |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Junk Filter doesn't filter | Live Mail | |||
| MVP's, text to speech!!, Can I dictate in other text input program | Vista General | |||
| Howto: Add lines of text from a specific point in a text file.. | VB Script | |||
| How do I read a text file and sort text by fixed positions? | PowerShell | |||
| help. Digital filter? how to de-filter? USB audio device | Vista hardware & devices | |||