Is it possible to run a DSC configuration and get the WhatIf output from Set-TargetResource? I've written a custom resource, and the Set function has all the necessary code for WhatIf/ShouldProcess to work (and indeed, if you call Set-TargetResource manually with -WhatIf, it works as expected).
When calling Start-DSCConfiguration with -WhatIf, all I get is this:
What if: [SERVERNAME]: LCM: [ Start Set ]
What if: [SERVERNAME]: LCM: [ Start Resource ] [[Isi_Share]test]
What if: [SERVERNAME]: LCM: [ Start Test ] [[Isi_Share]test]
What if: [SERVERNAME]: LCM: [ End Test ] [[Isi_Share]test] in 0.0310 seconds.
What if: [SERVERNAME]: LCM: [ Skip Set ] [[Isi_Share]test]
What if: [SERVERNAME]: LCM: [ End Resource ] [[Isi_Share]test]
What if: [SERVERNAME]: LCM: [ Start Resource ] [[Isi_Share]test2]
What if: [SERVERNAME]: LCM: [ Start Test ] [[Isi_Share]test2]
What if: [SERVERNAME]: LCM: [ End Test ] [[Isi_Share]test2] in 0.0470 seconds.
What if: [SERVERNAME]: LCM: [ Start Set ] [[Isi_Share]test2]
What if: [SERVERNAME]: LCM: [ End Set ] [[Isi_Share]test2] in 0.0150 seconds.
What if: [SERVERNAME]: LCM: [ End Resource ] [[Isi_Share]test2]
What if: [SERVERNAME]: LCM: [ End Set ]
When what I really want is for it to call the Test function for real, and then call Set with -WhatIf so that I get this output (generated by my calls to ShouldProcess() within Set-TargetResource:
What if: Performing the operation "Create Directory" on target "/ifs/a".
What if: Performing the operation "Create Share" on target "/ifs/a".
Is that possible?
No, you cannot do that. Manually is the only way for it to work.
As you experienced, the -whatif will tell you what resources would get called but does not call them. Your function needs to get called for the whatif inside it to process.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.