fix for olde versions of Powershell

This commit is contained in:
2021-07-29 13:01:54 -04:00
parent 786ca1f983
commit e8812e22ff
+5 -4
View File
@@ -29,11 +29,12 @@ If ( Test-Path "${ProgramFiles(x86)}\N-able Technologies\Windows Software Probe\
}
## Remove NablePatchRepositoryService
$Service = Get-Service -Name NablePatchRepositoryService -ErrorAction SilentlyContinue
$ServiceName = "NablePatchRepositoryService"
$Service = Get-Service -Name $ServiceName -ErrorAction SilentlyContinue
If ( $Service.Length -gt 0 ) {
Control-Service -Stop -Name $Service.ServiceName
LogMsg "Deleting the service: ""NablePatchRepositoryService"""
Try { $Service | Remove-Service }
Control-Service -Stop -Name $ServiceName
LogMsg "Deleting the service: ""${ServiceName}"""
Try { Start-Process "sc" -ArgumentList "delete ${ServiceName}" -Wait }
Catch { LogErr $_.Exception.Message }
}