Here are a few snippets of code that shows how to manipulate them. Simply include your default parameters in your profile and script on!
# Intitial creation (perhaps place in profile) $PSDefaultParameterValues=@{ "Send-MailMessage:SMTPServer"="smtp.osumc.edu"; "Send-MailMessage:From"="Automated.Email@osumc.edu"; "Get-Eventlog:logname"="Security"; } # Add another one $PSDefaultParameterValues.Add("Send-MailMessage:Bcc","PhatBeard@osumc.edu") # opps, need to modify the email address $PSDefaultParameterValues["Send-MailMessage:Bcc"]="FatBeard@osumc.edu" # Add another one (straight out of Get-Help) that utilizes a scriptblock
$PSDefaultParameterValues+=@{"Format-Table:AutoSize"={if ($host.Name –eq "ConsoleHost"){$true}}} # Remove one $PSDefaultParameterValues.Remove("Get-Eventlog:logname") # Remove all of them $PSDefaultParameterValues.Clear() # Temporarily disable all parameters $PSDefaultParameterValues.Add("Disabled", $true) # Remove the temporary disable $PSDefaultParameterValues.Remove("Disabled")Enjoy!
No comments:
Post a Comment