View Single Post
Old 12-30-2008   #2 (permalink)
RichS [MVP]


 
 

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 SpecsSystem Spec