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(DefaultParameterSetName="ProcessSet")] | |
param([parameter(Mandatory,ParameterSetName="ServiceSet")]$service, | |
[parameter(Mandatory,ParameterSetName="ProcessSet")]$Process, | |
$Test) | |
switch($PSCmdlet.ParameterSetName) | |
{ |
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) | |
{ |
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) | |
Write-host "Service: $service" -ForegroundColor Green | |
Write-host "Process: $process" -ForegroundColor Yellow | |
Write-host "test: $test" -ForegroundColor Magenta |
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(SupportsShouldProcess, | |
ConfirmImpact = "high")] | |
param($service) | |
if($PSCmdlet.ShouldProcess($service,"Fetch service")) | |
{ | |
get-service -name $service | |
} |
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(SupportsShouldProcess, | |
ConfirmImpact = "high")] | |
param($service) | |
if($PSCmdlet.ShouldProcess($service,"Fetch service")) | |
{ | |
get-service -name $service | |
} |
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(SupportsShouldProcess)] | |
param($service) | |
if($PSCmdlet.ShouldProcess($service,"Fetch service")) | |
{ | |
get-service -name $service | |
} | |
} | |
write-host "calling normally" -ForegroundColor Yellow |
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(SupportsShouldProcess)] | |
param() | |
Write-host "some host message" -ForegroundColor Green | |
} | |
MyFunction -WhatIf | |
MyFunction -Confirm |
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() | |
Write-error "Some custom error message" | |
Write-host "some host message" -ForegroundColor Green | |
get-process FAKE | |
} | |
write-host "running normally" -ForegroundColor Yellow |
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() | |
Write-verbose "Some verbose message" | |
Write-host "some host message" -ForegroundColor Green | |
} | |
write-host "running normally" -ForegroundColor Yellow | |
MyFunction |
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() | |
} |
NewerOlder