July 2018
Beginner
552 pages
13h 18m
English
We already saw that the cmdlet binding attribute will enable all common parameters for you. But there is much more to it.
One of the more popular settings concerns risk mitigation, by enabling the parameter WhatIf parameter to simulate a change and Confirm to confirm a change:
function withbinding{ [CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')] param ( ) if ($PSCmdlet.ShouldProcess('Target object','Action')) { Write-Host 'User answered yes in confirmation' }}withbinding -WhatIfwithbindingwithbinding -Confirm:$false
In order to make good use of these parameters, you should pay attention to the ConfirmImpact property. It correlates with the built-in $ConfirmPreference variable. If the confirm impact is ...
Read now
Unlock full access