Private/Association/Remove-JCAssociation.ps1
Function Remove-JCAssociation { [CmdletBinding(DefaultParameterSetName = 'ById')] Param( [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 1, HelpMessage = 'The type of the object.')][ValidateNotNullOrEmpty()][ValidateSet('command', 'ldap_server', 'policy', 'application', 'radius_server', 'system_group', 'system', 'user_group', 'user', 'g_suite', 'office_365')][Alias('TypeNameSingular')][string]$Type ) DynamicParam { $Action = 'remove' # Build dynamic parameters $RuntimeParameterDictionary = Get-DynamicParamAssociation -Action:($Action) -Type:($Type) Return $RuntimeParameterDictionary } Begin { # Debug message for parameter call Invoke-Command -ScriptBlock:($ScriptBlock_DefaultDebugMessageBegin) -ArgumentList:($MyInvocation, $PsBoundParameters, $PSCmdlet) -NoNewScope $Results = @() } Process { # For DynamicParam with a default value set that value and then convert the DynamicParam inputs into new variables for the script to use Invoke-Command -ScriptBlock:($ScriptBlock_DefaultDynamicParamProcess) -ArgumentList:($PsBoundParameters, $PSCmdlet, $RuntimeParameterDictionary) -NoNewScope # Create hash table to store variables $FunctionParameters = [ordered]@{} # Add input parameters from function in to hash table and filter out unnecessary parameters $PSBoundParameters.GetEnumerator() | ForEach-Object {$FunctionParameters.Add($_.Key, $_.Value) | Out-Null} # Add parameters from the script to the FunctionParameters hashtable $FunctionParameters.Add('Action', $Action) | Out-Null # Run the command $Results += Invoke-JCAssociation @FunctionParameters } End { Return $Results } } |