mirror of
https://github.com/PowerShell/PSDscResources
synced 2026-06-21 13:45:29 +00:00
27 lines
683 B
PowerShell
27 lines
683 B
PowerShell
$errorActionPreference = 'Stop'
|
|
Set-StrictMode -Version 'Latest'
|
|
|
|
<#
|
|
.SYNOPSIS
|
|
Stops all instances of the process with the given name.
|
|
|
|
.PARAMETER ProcessName
|
|
The name of the process to stop.
|
|
#>
|
|
function Stop-ProcessByName
|
|
{
|
|
[CmdletBinding()]
|
|
param
|
|
(
|
|
[Parameter(Mandatory = $true)]
|
|
[String]
|
|
$ProcessName
|
|
)
|
|
|
|
Stop-Process -Name $ProcessName -ErrorAction 'SilentlyContinue' -Force
|
|
Wait-ScriptBlockReturnTrue -ScriptBlock { return $null -eq (Get-Process -Name $ProcessName -ErrorAction 'SilentlyContinue') } `
|
|
-TimeoutSeconds 15
|
|
}
|
|
|
|
Export-ModuleMember -Function Stop-ProcessByName
|