PowerTip: Find Array Members with Get-Member in PowerShell

Doctor Scripto

Dr Scripto

Summary: Learn to find members of an array with the Get-Member cmdlet in Windows PowerShell.

Hey, Scripting Guy! Question I have an array of numbers: 1,2,3,4,5 that I assigned to variable $a. When I pipe it to Get-Member: $a | gm,
           all I see are members for int32. How can I find the members of an array by using Get-Member?

Hey, Scripting Guy! Answer There are two ways to do this:

1. Use the uniary operator ( ) in front of the array prior to piping it to Get-Member:

PS C:\> $a = 1,2,3,4,5

PS C:\> ,$a | get-member

2. Use the –InputObject parameter with Get-Member:

Get-Member -InputObject $a


Comments are closed.