added placeholder and paramset for deleting a service in Control-Service function
added service removal in Uninstall-NCentralComponents.ps1
This commit is contained in:
@@ -287,7 +287,7 @@ Function IsMemberOf {
|
||||
Return ([Security.Principal.WindowsPrincipal][System.Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole($Group)
|
||||
}
|
||||
|
||||
## Start, stop, or restart a list of services
|
||||
## Start, stop, restart, or delete a list of services
|
||||
Function Control-Service
|
||||
{
|
||||
param(
|
||||
@@ -297,13 +297,17 @@ Function Control-Service
|
||||
[switch]$Stop,
|
||||
[Parameter(Mandatory=$true,ParameterSetName='restart')]
|
||||
[switch]$Restart,
|
||||
[Parameter(Mandatory=$true,ParameterSetName='delete')]
|
||||
[switch]$Delete,
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName='start')]
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName='stop')]
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName='restart')]
|
||||
[Parameter(Mandatory=$true,ValueFromPipeline=$true,ParameterSetName='delete')]
|
||||
[string[]]$Name,
|
||||
[Parameter(Mandatory=$false,ParameterSetName='start')]
|
||||
[Parameter(Mandatory=$false,ParameterSetName='stop')]
|
||||
[Parameter(Mandatory=$false,ParameterSetName='restart')]
|
||||
[Parameter(Mandatory=$false,ParameterSetName='delete')]
|
||||
[switch]$Match=$false
|
||||
)
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
@@ -329,6 +333,9 @@ Function Control-Service
|
||||
Invoke-Expression $StartCmd
|
||||
Exit
|
||||
}
|
||||
'delete' {
|
||||
## Delete the service
|
||||
}
|
||||
}
|
||||
ForEach ( $item in $Name ) {
|
||||
$service = Get-Service -Name $item -ErrorAction SilentlyContinue
|
||||
|
||||
@@ -28,6 +28,15 @@ If ( Test-Path "${ProgramFiles(x86)}\N-able Technologies\Windows Software Probe\
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
|
||||
## Remove NablePatchRepositoryService
|
||||
$Service = Get-Service -Name NablePatchRepositoryService -ErrorAction SilentlyContinue
|
||||
If ( $Service.Length -gt 0 ) {
|
||||
Control-Service -Stop -Name $Service.ServiceName
|
||||
LogMsg "Deleting the service: ""NablePatchRepositoryService"""
|
||||
Try { $Service | Remove-Service }
|
||||
Catch { LogErr $_.Exception.Message }
|
||||
}
|
||||
|
||||
## Remove "MspPlatform" directory
|
||||
If ( Test-Path "${Env:ProgramFiles(x86)}\MspPlatform" ) {
|
||||
LogMsg "Forcefully removing ""${Env:ProgramFiles(x86)}\MspPlatform"""
|
||||
|
||||
Reference in New Issue
Block a user