Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Find Array Members with Get-Member in PowerShell

$
0
0

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


Viewing all articles
Browse latest Browse all 3333

Trending Articles