PowerShell: Hashtable Key / Property Name Clash

By Xah Lee. Date: .

Key Name Conflict with Property Name

If a key has same name as a hashtable property name, the key takes priority.

To access property, use .psbase.propertyName

$dict = [ordered] @{"keys" = 1; "b" = 2; }

# key name has priority
$dict.keys
# 1

# get all the keys
$dict.psbase.keys
<#
keys
b
#>

PowerShell Hashtable, Dictionary