I'm just a starter, dry-run is pretty useful to make a parameter to test, can any body tell me how to use it with an easy way? I googled that but few results on its uses.
Thank you very much
I'm just a starter, dry-run is pretty useful to make a parameter to test, can any body tell me how to use it with an easy way? I googled that but few results on its uses.
Thank you very much
You are probably referring to the
-WhatIf
and-Confirm
parameters on cmdlets. You can read up about them inGet-Help about_commonParameters
:Use on existing cmdlets
Explicitly supply the -WhatIf parameter:
Result:
Use on existing cmdlets within a function or script
SupportsShouldProcess
attribute automatically propagates-WhatIf
to supported cmdlets:Result:
Use on your own code blocks
Explicitly use
ShouldProcess()
method to determine whether-WhatIf
was passed:Result:
Use on Nested functions in the same module
SupportsShouldProcess
attribute automatically propagates-WhatIf
to nested functions:Result:
Use on Nested functions in a different module
Unfortunately, -WhatIf does not propagate automatically to functions defined in a different module. See Powershell: How to get -whatif to propagate to cmdlets in another module for discussion and workaround for this.