Public/Get-BaseParameters.ps1
using namespace System.Management.Automation using namespace System.Management.Automation.Internal function Get-BaseParameters { [CmdletBinding()] param( [Parameter(Position = 0, Mandatory)] [ValidateNotNullOrEmpty()] [string] $BaseFunction ) $BaseCommand = Get-Command $BaseFunction $CommonParameters = [CommonParameters].GetProperties().Name if ($BaseCommand) { $Dictionary = [RuntimeDefinedParameterDictionary]::new() foreach ($Parameter in $BaseCommand.Parameters.GetEnumerator()) { $Value = $Parameter.Value $Key = $Parameter.Key if ($Key -notin $CommonParameters) { $Parameter = [RuntimeDefinedParameter]::new( $Key, $Value.ParameterType, $Value.Attributes) $Dictionary.Add($Key, $Parameter) } } return $Dictionary } } |