Question:
Can anyone tell me how to add a parameter to my custom C# cmdlets which is a Hashtable/StringDictionary, so that I can call my cmdlet in a way which resembles this:
1 2 3 4 5 6 7 8 |
CustomCmdlet -File $someFilePath ` -StringDictionary/HashtableParameter @{ "name1"="value1" "name2"="value2" "name3"="value3" ... } |
I simply cannot find any documentation/example which clearly and simple explains how to do this, or if its even possible for custom cmdlets.
Can i just use:
1 2 3 4 5 6 7 8 |
[Parameter(Mandatory = false, Position = 9)] public Dictionary [Parameter(Mandatory = false, Position = 9)] public HashTable FieldValues { get; set; } ... |
Or something else?
Kind regards
Answer:
You can use the following
1 2 |
public Hashtable[] SearchCriteria { get; set; } |
to have the funcitonality like
1 2 |
Start-Process calc -PassThru | Get-UIAWindow | Get-UIAButton -SearchCriteria @{automationid="13*";name="[3-5]"},@{name="c*"},@{name="a*"},@{isenabled="false"} | Read-UIAControlName |
The output is
4
Clear entry
5
Clear
3
Add
Maximize
Close