Modifying default cmdlet parameters

Hello,

You can modify default behavior of all cmdlets by editing the “PSDefaultParameterValues”  variable :

$PSDefaultParameterValues | Get-Member

DefaultParameter-1

You can edit it like that :

$PSDefaultParameterValues["Write-Host:ForeGroundColor"] = "Green"

Before :

DefaultParameter-Before

After :

DefaultParameter-After

You can see all past modification like this :

$PSDefaultParameterValues

And delete them :

$PSDefaultParameterValues.Clear()

DefaultParameter-Resume

I just put some of those in my profile, pretty handy !

Leave a Reply