File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
reference/docs-conceptual/learn/deep-dives Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -141,6 +141,11 @@ Notice that I did not create a parameter called `-WhatIf`. Specifying `SupportsS
141141automatically creates it for us. When we specify the ` -WhatIf ` parameter on ` Test-ShouldProcess ` ,
142142some things we call also perform ` -WhatIf ` processing.
143143
144+ > [ !NOTE]
145+ > When you use ` SupportsShouldProcess ` , PowerShell doesn't add the ` $WhatIf ` variable to the
146+ > function. You don't need to check the value of ` $WhatIf ` because the ` ShouldProcess() ` method
147+ > takes care of that for you.
148+
144149### Trust but verify
145150
146151There's some danger here trusting that everything you call inherits ` -WhatIf ` values. For the rest
@@ -537,7 +542,7 @@ function Test-ShouldProcess {
537542
538543We add our own ` -Force ` switch as a parameter. The ` -Confirm ` parameter is automatically added when
539544using ` SupportsShouldProcess ` in the ` CmdletBinding ` . However, when you use ` SupportsShouldProcess ` ,
540- PowerShell doesn't add the ` $Confirm ` parameter to the function. If you are running in Strict Mode
545+ PowerShell doesn't add the ` $Confirm ` variable to the function. If you are running in Strict Mode
541546and try to use the ` $Confirm ` variable before it has been defined, you get an error. To avoid the
542547error you can use ` $PSBoundParameters ` to test if the parameter was passed by the user.
543548
You can’t perform that action at this time.
0 commit comments