I had mentioned earlier that when you pipe an array to the get-member cmdlet the array is unraveled.
While reading Bruce Payette’s excellent “Powershell in Action” book yesterday (and also coincidentally from an unrelated serverfault topic I was reading) I discovered that it’s possible to modify this behavior by prepending a , to the array. Like thus:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# the default behaviour PS> 1,2 | get-member TypeName: System.Int32 ... # my previous workaround was to use the -inputobject parameter PS> Get-Member -InputObject 1,2 TypeName: System.Object[] ... # you get a similar effect with the , operator PS> ,1,2 | gm TypeName: System.Object[] ... TypeName: System.Int32 ... PS> ,1,"abc",2 | gm TypeName: System.Object[] ... TypeName: System.String ... TypeName: System.Int32 ... |
Notice it gives the type of the array as well as the various sub-types within it (strings and integers). Useful!