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'
}
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for