Home Dashboard Directory Help
Search

Group-Object -Ashashtable for string values by stej


Status: 

Active


2
0
Sign in
to vote
Type: Bug
ID: 772015
Opened: 11/23/2012 12:17:52 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

Several times I found out that Group-Object doesn't behave the same way for strings and the other objects. Compare:

$x ='1', 'abc', 'text' | Group-Object -AsHashTable
$x.containsKey('1')            # returns false
$x['1'] -ne $null                 # returns false

but

$x = 1,2,3,2 | Group-Object -AsHashTable
$x.containsKey(2)            # returns true
$x[2]                                # returns the array

Futhermore when I just output
'1', 'abc', 'text' | Group-Object -AsHashTable
to the console, it looks like standard hashtable:
Name                         Value
----                         -----
text                         {text}
abc                            {abc}
1                                {1}

Keys collection contains '1', but the hashtable does not:
('1', 'abc', 'text' | Group-Object -ashashtable).keys -contains '1' #returns true
('1', 'abc', 'text' | Group-Object -ashashtable)['1']                         #returns $null

I'm running V2, maybe on V3 it is alredy fixed.. I have no chance to test it.
Details
Sign in to post a comment.
Sign in to post a workaround.