jrara
jrara

Reputation: 17011

How to find properties of an object?

How can I find what properties object $a has in the following?

$a = 1
$a.length
$a | Get-Member

Get-Member does not seem to produce any properties for object $a? Is length a property of object $a?

Upvotes: 35

Views: 53769

Answers (2)

Jeffery Hicks
Jeffery Hicks

Reputation: 141

You can also pipe a sample object to Select-Object to see all properties and their values.

get-process | select -first 1 -prop *

Upvotes: 14

Shay Levy
Shay Levy

Reputation: 126902

$a is an Integer, it doesn't have a length property. Using Get-member is the right way to find object properties.

Upvotes: 29

Related Questions