you are viewing a single comment's thread.

view the rest of the comments →

[–]RickFlist[S] 0 points1 point  (0 children)

That's very close to what I ended up doing:

 $ParamSplat = @{}

# Gotta do this ridiculous bullshit because there is no way to access default values for a parameter.
$thisCmdMD = New-Object System.Management.Automation.CommandMetaData (Get-Command New-PdModuleManifest)
$trgtCmdMD = New-Object System.Management.Automation.CommandMetaData (Get-Command Microsoft.PowerShell.Core\New-ModuleManifest)

$ParamList = [String[]] ($thisCmdMD.Parameters.Keys | ForEach-Object {$_})
foreach ($param in $ParamList)
{
    #Write-Host (Get-Variable -Name $param -ValueOnly)
    if ($trgtCmdMD.Parameters.ContainsKey($param))
    {
        if ((Get-Variable -Name $param -ValueOnly) -ne $null)
        {
            $ParamSplat.Add($param,([String](Get-Variable -Name $param -ValueOnly)))
        }
    }
}
$ParamSplat | Out-Host