Skip to content

Instantly share code, notes, and snippets.

@joswr1ght
Last active January 11, 2025 06:49
Show Gist options
  • Save joswr1ght/c5d9773a90a22478309e9e427073fd30 to your computer and use it in GitHub Desktop.
Save joswr1ght/c5d9773a90a22478309e9e427073fd30 to your computer and use it in GitHub Desktop.
Identify Hidden Windows Services
Compare-Object -ReferenceObject (Get-Service | Select-Object -ExpandProperty Name | % { $_ -replace "_[0-9a-f]{2,8}$" } ) -DifferenceObject (gci -path hklm:\system\currentcontrolset\services | % { $_.Name -Replace "HKEY_LOCAL_MACHINE\\","HKLM:\" } | ? { Get-ItemProperty -Path "$_" -name objectname -erroraction 'ignore' } | % { $_.substring(40) }) -PassThru | ?{$_.sideIndicator -eq "=>"}
@stryqx
Copy link

stryqx commented Sep 28, 2024

The following filters out any registry entries where the service has ObjectName set but is a driver (e.g. vmsmp, WUDFWpdFs, WUDFWpdMtp in the orginal one-liner):

Compare-Object -ReferenceObject (Get-Service | Select-Object -ExpandProperty Name | % { $_ -replace "_[0-9a-f]{2,8}$" } ) -DifferenceObject (gci -path hklm:\system\currentcontrolset\services | % { Get-ItemProperty $_.pspath } | ? { $_.ObjectName -ne $null -and ($_.Type -band 0xfffffff0) } | Select-Object -ExpandProperty PSChildName) -PassThru | ?{$_.sideIndicator -eq "=>"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment