Stop multiple processes

Description

This example shows how you can use the ProcessSet composite resource to ensure multiple processes are stopped.

With Ensure set to Absent and Path set to the array of C:\Windows\System32\cmd.exe and C:\TestPath\TestProcess.exe, the resource stops any running instances of cmd.exe and TestProcess.exe.

With Invoke-DscResource

The Invoke-DscResource cmdlet doesn't support invoking composite resources. Instead, use the WindowsProcess resource.

With a Configuration

This snippet shows how you can define a Configuration with a ProcessSet resource block to ensure the cmd.exe and TestProcess.exe processes are stopped.

Configuration Stop {
    Import-DscResource -ModuleName 'PSDscResources'

    Node localhost {
        ProcessSet ExampleProcessSet {
            Path   = @(
                'C:\Windows\System32\cmd.exe'
                'C:\TestPath\TestProcess.exe'
            )
            Ensure = 'Absent'
        }
    }
}