Advertisement
Guest User

Untitled

a guest
May 16th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. param (
  2.  
  3.     [string]$computer = ".",
  4.  
  5.     [switch]$outHTML,
  6.  
  7.     [switch]$outGrid
  8.  
  9. )
  10.  
  11.  
  12.  
  13. $results = (Get-WmiObject -Class Win32_Process -ComputerName $computer -Filter "Name='svchost.exe'" | % {
  14.  
  15.     $process = $_
  16.  
  17.     Get-WmiObject -Class Win32_Service -ComputerName $computer -Filter "ProcessId=$($_.ProcessId)" | % {
  18.  
  19.         New-Object PSObject -Property @{ProcessId=$process.ProcessId;
  20.  
  21.                                         CommittedMemory=$process.WS;
  22.  
  23.                                         PageFaults=$process.PageFaults;
  24.  
  25.                                         CommandLine=$_.PathName;
  26.  
  27.                                         ServiceName=$_.Name;
  28.  
  29.                                         State=$_.State;
  30.  
  31.                                         DisplayName=$_.DisplayName;
  32.  
  33.                                         StartMode=$_.StartMode}
  34.  
  35.     }
  36.  
  37. })
  38.  
  39.  
  40.  
  41. if ($outHTML)
  42.  
  43. {
  44.  
  45.     $results | ConvertTo-Html | Out-File ".\temp.html"
  46.  
  47.     & .\temp.html
  48.  
  49. }
  50.  
  51.  
  52.  
  53. if ($outGrid)
  54.  
  55. {
  56.  
  57.     $results | Out-GridView
  58.  
  59. }
  60.  
  61.  
  62.  
  63. $results
  64. Read-Host "Press any key to exit..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement