Remove-ALOpsExternalDeployer.ps1
function Remove-ALOpsExternalDeployer() { param ( [string] $ServiceName = "ALOpsExternalDeployer", [string] $InstallUtilPath ) $alopsService = get-service -Name $ServiceName -ErrorAction SilentlyContinue if ($null -eq $alopsService){ return } if ([string]::IsNullOrEmpty($InstallUtilPath)){ $InstallUtilPath = Get-DotnetInstallUtil } $tryCount = 0 Write-Host "*** Stopping existing service" -ForegroundColor Green Stop-Service -Name $ServiceName while ($alopsService.Status.ToString().ToUpper() -ne "Stopped".ToUpper() ){ $tryCount += 1; Start-Sleep -Seconds 1 $alopsService = get-service -Name $ServiceName if ($tryCount -gt 15){ $ServicePID = (get-wmiobject win32_service | Where-Object { $_.name -eq $ServiceName }).processID Stop-Process $ServicePID -Force } } Start-Sleep -Seconds 1 Write-Host "*** Uninstall existing service" -ForegroundColor Green $oldService = get-wmiobject win32_service | Where-Object { $_.name -eq $ServiceName} | Select-Object -Property Name, DisplayName, State, PathName Write-Host "$($oldService | format-list -Property * | out-string)" if ($ServiceName -eq "ALOpsExternalDeployer") { & "$($InstallUtilPath)" /u "$($oldService.PathName)" } else { & "sc.exe" delete "$($ServiceName)" $ServiceLocation = Get-Item -Path $oldService.PathName Write-Host "*** Cleanup folder: [$($ServiceLocation.Directory)]" Remove-Item -Path $ServiceLocation.Directory -Recurse -Confirm:$false -Force:$true } } |