pf-WinService.ps1
function Restart-ServiceScope { Param( $names, [ScriptBlock]$script ) begin { $services = @() } Process { $services += get-service -DisplayName $names -ErrorAction SilentlyContinue $services += get-service -Name $names -ErrorAction SilentlyContinue } end { $services | Stop-Service -Verbose try { . $script } finally { $services | Start-Service -Verbose } } } function Get-Service_StartMode($serviceName) { $result = Get-WmiObject -Query "Select StartMode From Win32_Service Where Name='$serviceName'" $result.StartMode } function Start-Service_Auto { $toStart = Get-Service | Where-Object Status -NE Running | Where-Object { ( Get-Service_StartMode $_.name ) -LIKE 'AUTO*'} $toStart = $toStart | Where-Object displayName -NotLike '*Google*' $toStart | Start-Service -Verbose } |