Case-Sensitive Hash Tables

by | June 13,2011

Table of Contents

Case-Sensitive Hash Tables

by | June 13,2011

PowerShell hash tables

PowerShell hash tables are, by default, not case sensitive:

PS > $hash = @{}
PS > $hash.Key = 1
PS > $hash.keY = 2
PS > $hash.KEY
2

Creating Case-Sensitive Hash Tables in PowerShell

If you need case-sensitive keys, you can create the hash table this way:

PS > $hash = New-Object system.collections.hashtable
PS > $hash.Key = 1
PS > $hash.keY = 2
PS > $hash.KEY
PS > $hash

Name                           Value
----                           -----
keY                            2
Key                            1

 

Twitter This Tip!
ReTweet this Tip!