Define DynamicKeyword 'ExecTest'
Note: Don't copy&paste from following code. PowerShell SyntaxHighlighter remove some lines. Instead, use RAW view.
#Requires -Version 4.0
Set-StrictMode -Version Latest
#Reset Existing Dynamic Keywords
[System.Management.Automation.Language.DynamicKeyword]::Reset()
#Add Dynamic Keyword
$keyword = New-Object System.Management.Automation.Language.DynamicKeyword
$keyword.Keyword ="ExecTest"
$keyword.BodyMode = [Management.Automation.Language.DynamicKeywordBodyMode]::HashTable
$keyword.NameMode = [Management.Automation.Language.DynamicKeywordNameMode]::NoName
$prop = New-Object System.Management.Automation.Language.DynamicKeywordProperty
$prop.Name="ABC"
$prop.Mandatory = $true
$keyword.Properties.Add($prop.Name,$prop)
[System.Management.Automation.Language.DynamicKeyword]::AddKeyword($keyword)
#Define Function to process DynamicKeyword
function ExecTest{
param (
[Parameter(Mandatory)]
$KeywordData,
[string[]] $Name,
[Parameter(Mandatory)]
[hashtable] $Value,
[Parameter(Mandatory)]
$SourceMetadata
)
$PSBoundParameters
}
Use DynamicKeyword 'ExecTest' Note: Execute command separately,DynamicKeyword need to defined before use.
ExecTest{
ABC = "abc"
}
good work.