Skip to content

Instantly share code, notes, and snippets.

@nyanhp
Created November 29, 2017 21:33
Show Gist options
  • Save nyanhp/c28ee163ac24c19c569a5c23981e1eee to your computer and use it in GitHub Desktop.
Save nyanhp/c28ee163ac24c19c569a5c23981e1eee to your computer and use it in GitHub Desktop.
Synchronize parameter sets
# 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