It seems that I cannot add an arbitrary key name to a hashtable
without overriding a member with that name if it already exists.
I create a hash table ($x
) and add two keys, one
and two
:
$x = @{}
$x['one'] = 1
$x['two'] = 2
The added keys are then shown by evaluating $x.Keys
:
$x.Keys
This prints:
one
two
If I add another key, named keys
, it overrides the already existing member:
$x['Keys'] = 42
$x.Keys
This now prints:
42
I am not sure if I find this behavior desirable. I had expected $x.keys
to print the key names and $x['keys']
to print 42
.
Is it somehow possible to add a key named Keys
without overriding the Keys
member?
$x.psobject.members['keys'].value
. – Cosby$x.psbase.keys
– Cosby