Public/Tasks/Invoke-KillProcessTask.ps1
#Requires -Modules WebAdministration Set-StrictMode -Version Latest Write-Verbose "Loading $($MyInvocation.MyCommand.Path)" Function Invoke-KillProcessTask { [CmdletBinding(SupportsShouldProcess=$true)] param( [Parameter(Mandatory=$true)] [string]$processId ) $message = "Killing process id: $processId" if ($PSCmdLet.ShouldProcess("$processId", "$message" )) { Write-TaskInfo $message -Tag 'KillProcess' try { Stop-Process -id $processId -Force -Confirm:$false } catch { Write-Warning $_.Exception.Message } } } Register-SitecoreInstallExtension -Command Invoke-KillProcessTask -As KillProcess -Type Task -Force Write-Verbose "Loaded $($MyInvocation.MyCommand.Path)" |