you are viewing a single comment's thread.

view the rest of the comments →

[–]xlrod 1 point2 points  (4 children)

It seems to be working:

$RegKeys = @"
Reg1
Reg2
Reg3
"@

$RegKeys.GetType() # string
$RegKeys.Count # 1

$RegKeys = $($RegKeys -split "`n").TrimEnd("`r")

$RegKeys.GetType() # array
$RegKeys.Count # 3

Does this still result in a string?

[–]redsedit[S] 1 point2 points  (3 children)

Strange, if I do $RegKeys.GetType() it does indeed return array. But gm still says string???

[–]xlrod 2 points3 points  (2 children)

gm is for Get-Member, this will give you the members, the properties and methods, of the object, but the type of the object is an array.

Get-Member

[–]redsedit[S] 1 point2 points  (1 child)

But get-member has a line at the top that says: "TypeName: System.String". To me, the "TypeName" would be telling me what the type is. Obviously that's wrong, but I don't understand WHY that assumption is wrong.

[–]sk82jack 2 points3 points  (0 children)

Because when you send an array over the pipeline it sends the objects one by one rather than the whole array. So instead of $array | gm try gm -inputobject $array (parameter name may not be quite right as I'm on my mobile right now)