Skip to content

Instantly share code, notes, and snippets.

@Sambardo
Created February 28, 2018 20:02
Show Gist options
  • Save Sambardo/e1c0281af379642ff7062a81d53e745f to your computer and use it in GitHub Desktop.
Save Sambardo/e1c0281af379642ff7062a81d53e745f to your computer and use it in GitHub Desktop.
Function MyFunction
{
[cmdletbinding(SupportsShouldProcess)]
param($service)
if($PSCmdlet.ShouldProcess($service,"Fetch service"))
{
get-service -name $service
}
}
write-host "calling normally" -ForegroundColor Yellow
MyFunction -service alg
write-host "calling with whatif" -ForegroundColor Yellow
MyFunction -service alg -WhatIf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment