# find the service $Service = @(Get-Service-Name$ServiceName-ErrorAction Silent) # bail out if there is no such service if ($Service.Count -ne1) { Write-Warning"$ServiceName unknown." return }
# read the service privileges from registry $Path = 'HKLM:\SYSTEM\CurrentControlSet\Services\' + $service.Name $Privs = Get-ItemProperty-Path$Path-Name RequiredPrivileges