2,187
edits
(Initial creation - content from Variables page) |
m (→Hashtables: Added loop) |
||
Line 86: | Line 86: | ||
$hash["Name"] = "Value" # Add value to end of array | $hash["Name"] = "Value" # Add value to end of array | ||
$hash.GetEnumerator() | Sort-Object -Property Name # Sort hashtable | $hash.GetEnumerator() | Sort-Object -Property Name # Sort hashtable | ||
</source> | |||
To loop through a hash table | |||
<source lang="powershell"> | |||
$hash.Keys | % { | |||
Write-Host "key = $_" | |||
Write-Host "value = " + $hash.Item($_) | |||
} | |||
</source> | </source> | ||
[[category:PowerShell]] | [[category:PowerShell]] | ||
[[category:Variables (PowerShell)]] | [[category:Variables (PowerShell)]] |