Tests/Unit/MSFT_xProcessResource.TestHelper.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Import-Module "$PSScriptRoot\..\CommonTestHelper.psm1"

<#
    .SYNOPSIS
    Stops all instances of a process using the process name.
#>

function Stop-ProcessByName
{
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [String]
        $ProcessName
    )

    Stop-Process -Name $ProcessName -Force -ErrorAction SilentlyContinue
    Wait-ScriptBlockReturnTrue -ScriptBlock {$null -eq (Get-Process -Name $ProcessName -ErrorAction SilentlyContinue)} -TimeoutSeconds 15
}

Export-ModuleMember -Function Stop-ProcessByName