Simple Hashtable in PowerShell

email me

Hashtables are a great way to format custom data, change labels on columns, and adjusts column widths.

Code

cls
$TheHashTable = new-object system.collections.hashtable
$TheHashTable += @{"Washington" = "Olympia"; "Oregon" = "Salem"; "California" = "Sacremento" }
$a = @{Expression={$_.Name};Label="Test1";width=15}, `
@{Expression={$_.Value};Label="Test2";width=30}

"The Hashtable contents:"
$TheHashTable | Format-Table $a

 
 
Output (copy and pasted into PowerShell)
 

 
 
Reference

https://technet.microsoft.com/en-us/library/ee692803.aspx?f=255&MSPPError=-2147217396