Skip to content

Commit

Permalink
added logic on process message
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmelton committed Oct 25, 2019
1 parent 5861daa commit a0fdc0d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cleanup.ps1
Expand Up @@ -47,11 +47,13 @@ if ( ($olderVersions.Count -gt 0) -and $newestVersion.Version -in $installedVers
} else {
$processes = Get-Process $process -ErrorAction SilentlyContinue | Where-Object Id -NE $PID
}
if ($Pscmdlet.ShouldProcess("$env:COMPUTERNAME", "Killing $($processes.Count) processes of powershell running")) {
Write-Output "Death to the following process(es): $(($processes.Id) -join ",")"
$processes | Stop-Process -ErrorVariable dangit -ErrorAction SilentlyContinue -Force
if ($dangit) {
Write-Warning "Not able to kill following processes: $((Get-Process $process | Where-Object Id -NE $pid).Id -join ",")"
if ($processes.Count -gt 0) {
if ($Pscmdlet.ShouldProcess("$env:COMPUTERNAME", "Killing $($processes.Count) processes of powershell running")) {
Write-Output "Death to the following process(es): $(($processes.Id) -join ",")"
$processes | Stop-Process -ErrorVariable dangit -ErrorAction SilentlyContinue -Force
if ($dangit) {
Write-Warning "Not able to kill following processes: $((Get-Process $process | Where-Object Id -NE $pid).Id -join ",")"
}
}
}
if ($Pscmdlet.ShouldProcess("$env:COMPUTERNAME", "Removing old versions of $module.")) {
Expand Down

0 comments on commit a0fdc0d

Please sign in to comment.