Guest User

Uninstall-Service

a guest
Oct 25th, 2016
718
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Uninstall-Service {
  2. <#    
  3. .SYNOPSIS
  4. Function to uninstall Service
  5.  
  6. .INFO
  7. Must use SERVICE NAME, not SERVICE DESCRIPTION! (service name is typically the .exe name)
  8.  
  9. #>    
  10.     Param(
  11.     [Parameter( Mandatory = $true )]
  12.     $serviceName
  13.     )
  14.  
  15.     $serv = Get-WmiObject -Class win32_service | where {$_.Name -eq $serviceName}
  16.     $serv.StopService()
  17.     $serv.Delete()
  18. }
Advertisement
Add Comment
Please, Sign In to add comment