Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: General » microsoft.public.windows.powershell
Thread: filter out text..

HTVi
TV Discussion Newsgroups

filter out text..
rferrisx <rferris[ at ]rmfdevelopment.com> 12/30/2008 5:36:00 PM
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
RE: filter out text..
RichS [MVP] 12/30/2008 6:41:01 PM
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:

[Quoted 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
>
Re: filter out text..
"Keith Hill [MVP]" <r_keith_hill[ at ]mailhot.moc.no_spam_I> 12/30/2008 10:48:20 PM
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=[ at ]{}; $then | %{$ht[$_.Id]=$_}
133> $now | ? {$ht[$_.Id] -and $ht[$_.id].WorkingSet -ne $_.WorkingSet} |
Select Name, [ at ]{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[ at ]rmfdevelopment.com> wrote in message
news:dc972cd9-cd81-4112-9cf5-f93d03af1201[ at ]q26g2000prq.googlegroups.com...
[Quoted 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

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen