Created
November 29, 2017 21:33
-
-
Save nyanhp/c28ee163ac24c19c569a5c23981e1eee to your computer and use it in GitHub Desktop.
Synchronize parameter sets
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
# Use AutomatedLabs little helpers in your own code aka steal our stuff | |
$parameterTable = @{ | |
Name = 'PowerShell' | |
WeirdParameter = 'Does not compute :(' | |
} | |
$nicerParameters = Sync-Parameter -Command (Get-Command Get-Process) -Parameters $parameterTable | |
Get-Process @nicerParameters | |
# Also ideally suited when using PSBoundParameters which we all love very much | |
function Get-Stuff | |
{ | |
param | |
( | |
[string] | |
$ComputerName, | |
[switch] | |
$SomeSwitch, | |
[datetime] | |
$After | |
) | |
$nicerParameters = Sync-Parameter -Command (Get-Command Get-EventLog) -Parameters $PSBoundParameters | |
Get-Eventlog -logname System @nicerParameters | |
} | |
Get-Stuff -ComputerName DC1 -SomeSwitch -After (Get-Date).AddDays(-14) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment