Private/Get-FunctionParameters.ps1
function Get-FunctionParameters() { <# .SYNOPSIS Simple function to get Function Parameters .NOTES Version: 1.0.0 Author: Thomas ILLIET Creation Date: 21/07/2018 #> # Get the command name $CommandName = $PSCmdlet.MyInvocation.InvocationName; # Get the list of parameters for the command $ParameterList = (Get-Command -Name $CommandName).Parameters; # Grab each parameter value, using Get-Variable $Params = @{} foreach ($Parameter in $ParameterList) { $ParameterObjects = Get-Variable -Name $Parameter.Values.Name -ErrorAction SilentlyContinue foreach($ParameterObject in $ParameterObjects){ if(([string]::IsNullOrEmpty($ParameterObject.Value)) -eq $False) { $Params[$ParameterObject.Name] = $ParameterObject.Value } } } return $Params } |