Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param (
- [string]$computer = ".",
- [switch]$outHTML,
- [switch]$outGrid
- )
- $results = (Get-WmiObject -Class Win32_Process -ComputerName $computer -Filter "Name='svchost.exe'" | % {
- $process = $_
- Get-WmiObject -Class Win32_Service -ComputerName $computer -Filter "ProcessId=$($_.ProcessId)" | % {
- New-Object PSObject -Property @{ProcessId=$process.ProcessId;
- CommittedMemory=$process.WS;
- PageFaults=$process.PageFaults;
- CommandLine=$_.PathName;
- ServiceName=$_.Name;
- State=$_.State;
- DisplayName=$_.DisplayName;
- StartMode=$_.StartMode}
- }
- })
- if ($outHTML)
- {
- $results | ConvertTo-Html | Out-File ".\temp.html"
- & .\temp.html
- }
- if ($outGrid)
- {
- $results | Out-GridView
- }
- $results
- Read-Host "Press any key to exit..."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement