Display SvcHost processes

Version: 1.0.1
Creator Name: ControlUp Support
Date Created: 2014-09-02
Date Modified: 2014-09-02
Scripting language: PS
Download Count: 476

This script looks at all of the services running under svchost.exe (a generic wrapper) and tells which service is using which wrapper.
Tags: services,PowerShell

The Script

param (
    [string]$computer = "."
)
$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}
    	}
       }
)
$results