February 2019
Intermediate to advanced
626 pages
15h 51m
English
RuntimeDefinedParameterDictionary is the expected output from the dynamicparam block. The dictionary must contain all of the dynamic parameters a function is expected to present.
The following example creates a dictionary and adds a single parameter:
using namespace System.Management.Automationfunction Test-DynamicParam { [CmdletBinding()] param ( ) dynamicparam { $paramDictionary = [RuntimeDefinedParameterDictionary]::new() $parameter = [RuntimeDefinedParameter]::new('Action', [String], [Attribute[]]@( [Parameter]@{ Mandatory = $true; Position = 1 } [ValidateSet]::new('Start', 'Stop', 'Create', 'Delete') ) ) $paramDictionary.Add($parameter.Name, $parameter) $paramDictionary }}
Read now
Unlock full access