Skip to content

Instantly share code, notes, and snippets.

@dustinchilson
Created January 4, 2017 19:58
Show Gist options
  • Save dustinchilson/67783b9ce36217eefd7230d504adad7f to your computer and use it in GitHub Desktop.
Save dustinchilson/67783b9ce36217eefd7230d504adad7f to your computer and use it in GitHub Desktop.
Delete windows services with a string in the name
foreach ($service in get-wmiobject win32_service |
where { $_.name -like "*TestString*"} ) {
if ($service.ProcessId -ne 0) {
Stop-Process $service.ProcessId -Force
}
& "sc.exe" delete $service.Name
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment