Archive for March, 2008
PS C:\> Get-Process | Sort-Object -Property cpu -Descending
Posted by: Preetam on March 20, 2008
PS C:\> Get-Process | Sort-Object -Property cpu -Descending | Select-Object -First 10
Posted by: Preetam on March 20, 2008
PS C:\> get-help out-* | Format-List name,synopsis
Posted by: Preetam on March 20, 2008
Get-Service | Sort-Object status -des
Posted by: Preetam on March 20, 2008
Get-Service | Sort-Object status -des | ForEach-Object {write-host $_.Displayname "<=|=|=>" $_.status}
Posted by: Preetam on March 20, 2008
PS C:\> Get-Service | ForEach-Object {if($_.status -eq "running"){write-host $_.Displayname $_.status -ForegroundColor Green} else{write-host $_.displayname $_.status -foreground red} }
Posted by: Preetam on March 20, 2008
Get-Service | sort-object status | ConvertTo-Html Name,Status | out-file services.htm
Posted by: Preetam on March 20, 2008
PS C:\> Get-Service | ConvertTo-Html Name,Status | foreach{ >> if($_ -like "*<TD>Running</TD>*"){$_ -replace "<tr>","<tr bgcolor=green>"} >> else{$_ -replace "<TR>","<TR bgcolor=red>"}} | out-file servicescolors.htm
Posted by: Preetam on March 20, 2008
PS FK:\> ls * -Exclude *.tmp | sort-object length -des | Select-Object -First 10 name,length
Posted by: Preetam on March 20, 2008
PS FK:\> Get-ChildItem | Group-Object extension | Sort-Object count
Posted by: Preetam on March 20, 2008