How do you support PowerShell's -WhatIf & -Confirm parameters in a Cmdlet that calls other Cmdlets?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a PowerShell script cmdlet that supports the -WhatIf & -Confirm parameters. It does this by calling the $PSCmdlet.ShouldProcess() method before performing the change. This works as expected. The problem I have is that my Cmdlet is implemented by calling other Cmdlets and the -WhatIf or -Confirm parameters are not passed along to the Cmdlets I invoke. How can I pass along the values of -WhatIf and -Confirm to the Cmdlets I call from my Cmdlet? For example, if my Cmdlet is Stop-CompanyXyzServices and it uses Stop-Service to implement