Reputation: 35
I am trying to convert values under 'key' column to a single string delimited with ','
$TheTable = (get-command get-mailbox).Parameters
Command returns:
Key Value
--- -----
ErrorAction System.Management.Automation.ParameterMetadata
IncludeInactiveMailbox System.Management.Automation.ParameterMetadata
Verbose System.Management.Automation.ParameterMetadata
OutVariable System.Management.Automation.ParameterMetadata
I am trying to achieve:
$TheTable = "ErrorAction,IncludeInactiveMailbox,Verbose,OutVariable"
I am completely lost as everything I attempt (foreach loop, .ToString) returns:
System.Collections.Generic.Dictionary`2[System.String,System.Management.Automation.ParameterMetadata],
Is there any way too do that?
Upvotes: 1
Views: 1164
Reputation: 437548
To get a hashtable's / dictionary's keys, use its .Keys
property.
To convert a collection of strings to a single string with a separator, use the -join
operator.
Therefore:
$TheTable = (get-command get-mailbox).Parameters.Keys -join ","
Upvotes: 2