Skip to content

Instantly share code, notes, and snippets.

@Sambardo
Created February 28, 2018 20:22
Show Gist options
  • Save Sambardo/ec3393e0435ccf496f5ba315792ae7f7 to your computer and use it in GitHub Desktop.
Save Sambardo/ec3393e0435ccf496f5ba315792ae7f7 to your computer and use it in GitHub Desktop.
Function MyFunction
{
[cmdletbinding(DefaultParameterSetName="ProcessSet")]
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 NO PARAMS" -ForegroundColor Cyan
MyFunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment