Forked from TylerLeonhardt/sillyparameterchecking.ps1
Last active
January 17, 2019 20:21
-
-
Save SimonWahlin/f8577c4604d2cdbc88e9a0262a7558fe to your computer and use it in GitHub Desktop.
silly parameter checking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Send-PSNotification { | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory,ValueFromPipeline,Position=0)] | |
[object] | |
$Body, | |
[String] | |
$Summary = 'PowerShell Notification', | |
[ValidateSet('low', 'normal', 'critical')] | |
$Urgency, | |
[int] | |
$ExpireTime, | |
[string[]] | |
$Icon = "powershell-logo", | |
[string[]] | |
$Category, | |
[string] | |
[ValidateNotNullOrEmpty()] | |
$SoundFile | |
) | |
$notifySendArgs = switch ($PSBoundParameters.Keys) { | |
'Urgency' { "--urgency=$Urgency" } | |
'ExpireTime' { "--expire-time=$ExpireTime" } | |
'Catagory' { "--category=$($Catagory -join ',')" } | |
'SoundFile' { "--hint=string:sound-file:$SoundFile" } | |
'Icon' { | |
if ($Icon -eq "powershell-logo") { | |
Add-DefaultPSIcon | |
} | |
"--icon=$($Icon -join ',')" | |
} | |
Default {} | |
} | |
$notifySendArgs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment