Created
February 28, 2018 20:20
-
-
Save Sambardo/813703f7eca5b292cfc9e93c5f4c2221 to your computer and use it in GitHub Desktop.
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 MyFunction | |
{ | |
[cmdletbinding()] | |
param([parameter(Mandatory,ParameterSetName="ServiceSet")]$service, | |
[parameter(Mandatory,ParameterSetName="ProcessSet")]$Process, | |
$Test) | |
switch($PSCmdlet.ParameterSetName) | |
{ | |
"ServiceSet" {Write-host "Service: $service" -ForegroundColor Green} | |
"ProcessSet" {Write-host "Process: $process" -ForegroundColor Yellow} | |
} | |
if($test) | |
{ | |
Write-host "test: $test" -ForegroundColor Magenta | |
} | |
} | |
write-host "about to call with -service" -ForegroundColor Cyan | |
MyFunction -service alg -test hi | |
write-host "about to call with -process" -ForegroundColor Cyan | |
MyFunction -Process powershell -Test bye |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment