[英]PowerShell Table column to string delimited with ','
我正在嘗試將“key”列下的值轉換為以“,”分隔的單個字符串
$TheTable = (get-command get-mailbox).Parameters
命令返回:
Key Value
--- -----
ErrorAction System.Management.Automation.ParameterMetadata
IncludeInactiveMailbox System.Management.Automation.ParameterMetadata
Verbose System.Management.Automation.ParameterMetadata
OutVariable System.Management.Automation.ParameterMetadata
我正在努力實現:
$TheTable = "ErrorAction,IncludeInactiveMailbox,Verbose,OutVariable"
當我嘗試的一切(foreach 循環,.ToString)返回時,我完全迷失了:
System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata],
有沒有辦法做到這一點?
要獲取哈希表/字典的鍵,請使用其.Keys
屬性。
要將字符串集合轉換為帶有分隔符的單個字符串,請使用-join
運算符。
所以:
$TheTable = (get-command get-mailbox).Parameters.Keys -join ","
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.