[英]Powershell C# Cmdlet with Hashtable/Dictionary parameters
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: 任何人都可以告诉我如何将参数添加到我的自定义C#cmdlet,这是一个Hashtable / StringDictionary,以便我可以以类似于这样的方式调用我的cmdlet:
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. 我根本找不到任何文档/示例,这些文档/示例清楚而简单地解释了如何执行此操作,或者甚至可以用于自定义cmdlet。
Can i just use: 我可以使用:
[Parameter(Mandatory = false, Position = 9)]
public Dictionary<string,string> FieldValues { get; set; }
[Parameter(Mandatory = false, Position = 9)]
public HashTable FieldValues { get; set; }
...
Or something else? 或者是其他东西?
Kind regards 亲切的问候
You can use the following 您可以使用以下内容
public Hashtable[] SearchCriteria { get; set; }
to have the funcitonality like 有这样的功能
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 4
Clear entry 明确的条目
5 五
Clear 明确
3 3
Add 加
Maximize 最大化
Close 关
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.