Tip: You can set some default values for parameters by using the automatic variable $PSDefaultParameterValues.
This preference variable is a hashtable and have some methods such as : Add, Clear, GetEnumerator, Remove, …
For example:
– if you want to have by default -Count 1 and -Quiet $true for Test-Connection.
– if you want to set a default server for Get-AD* cmdlets
1 2 3 4 5 |
For one cmdlet (Get-ADUser) $PSDefaultParameterValues = @{"Get-ADUser:Server"='DC01'} For all cmdlets (Get-AD*) $PSDefaultParameterValues = @{"Get-AD*:Server"='DC01'} |
Note: This change will be permanent only for this session but if you want to have these settings automatically defined everytime you open a new session, you can set them in your PowerShell profile. If you work with Powershell ISE, a quick way to do that: ise $profile
MSDN:
DefaultParameterDictionary Class