Public/Remove-DefaultParameterValue.ps1
function Remove-DefaultParameterValue { [CmdletBinding(SupportsShouldProcess, ConfirmImpact='Low')] param( [Parameter(Mandatory)] [Alias('Name')] [ValidateNotNullOrEmpty()] [string] $CmdletName , [Parameter(Mandatory)] [Alias('Parameter')] [ValidateNotNullOrEmpty()] [string] $ParameterName ) begin { if (-not $PSBoundParameters.ContainsKey('Confirm')) { $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference') } if (-not $PSBoundParameters.ContainsKey('WhatIf')) { $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference') } } process { if ($Force -or $PSCmdlet.ShouldProcess("Remove parameter '$ParameterName' from cmdlet '$CmdletName'?")) { $PSDefaultParameterValues.Remove("$($CmdletName):$ParameterName") } } } |