Last active
August 3, 2016 11:11
-
-
Save aetos382/78c9b8c450a4e8748b781102027765fa to your computer and use it in GitHub Desktop.
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 Get-CommonParameter { | |
[OutputType([Hashtable])] | |
[CmdletBinding( | |
SupportsShouldProcess)] | |
[System.Diagnostics.CodeAnalysis.SuppressMessage('PSShouldProcess', '')] | |
param( | |
[Parameter(ValueFromRemainingArguments)] | |
[PSObject[]] $Dummy) | |
$commonParameterNames = @() | |
$commonParameterNames += [System.Management.Automation.Cmdlet]::CommonParameters | |
$commonParameterNames += [System.Management.Automation.Cmdlet]::OptionalCommonParameters | |
$commonParameters = @{} | |
foreach ($name in $commonParameterNames) { | |
[Object] $val = $null | |
if ($PSBoundParameters.TryGetValue($name, [ref] $val)) { | |
$commonParameters[$name] = $val | |
} | |
} | |
return $commonParameters | |
} | |
function Hoge { | |
$commonParameters = Get-CommonParameter @PSBoundParameters | |
Function-In-Other-Module @commonParameters | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment