说明
此示例演示如何使用 ProcessSet
复合资源来确保停止多个进程。
通过“确保”设置为Absent
数组和“路径”设置为数组C:\Windows\System32\cmd.exe
C:\TestPath\TestProcess.exe
,资源将停止任何正在运行的cmd.exe
实例和 TestProcess.exe
。
使用 Invoke-DscResource
该 Invoke-DscResource
cmdlet 不支持调用复合资源。 请改用 WindowsProcess 资源。
使用配置
此代码片段演示如何使用ProcessSet
资源块定义,Configuration
以确保cmd.exe
停止和TestProcess.exe
进程。
Configuration Stop {
Import-DscResource -ModuleName 'PSDscResources'
Node localhost {
ProcessSet ExampleProcessSet {
Path = @(
'C:\Windows\System32\cmd.exe'
'C:\TestPath\TestProcess.exe'
)
Ensure = 'Absent'
}
}
}