Created
June 23, 2020 08:56
-
-
Save eizedev/1526ca103ff63aef43bc56318703bc13 to your computer and use it in GitHub Desktop.
Use Verbose or Debug advanced function parameters in an easy way in your own functions
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 DoStuff { | |
[CmdletBinding()] | |
param () | |
BEGIN | |
{ | |
$CMDOUT = @{ | |
Verbose = If ($PSBoundParameters.Verbose -eq $true) { $true } else { $false }; | |
Debug = If ($PSBoundParameters.Debug -eq $true) { $true } else { $false } | |
} | |
} # BEGIN ENDS | |
PROCESS | |
{ | |
New-Item Example -ItemType Directory @CMDOUT | |
} # PROCESS ENDS | |
END | |
{ | |
} #END ENDS | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment