I written a script to verify the services were succefully stopped If not it will kill the running processes. Below is my script.
Let me know what needs be added. I am very new to powershell.
$configData = (Get-Content (Join-Path $PSScriptRoot "config\gp.processes.Json") -Raw | ConvertFrom-Json)
$svcProcessList = $configData.UI
foreach ($svcProcess in $svcProcessList) {
Write-Output "::INFO::Looking for $svcProcess on $computerName to kill"
$sumOfReturnValues += stop-Process -processName $svcProcess -computerName $computerName
}
if($sumOfReturnValues -ne 0)
{
Write-Error "Unable to stop Services as I am unable to terminate all the related processes"
Exit 1
}
Error message "
A parameter cannot be found that matches parameter name 'computerName'