PowerTip: Determine if Property is Member of Object


Summary: Determine if a property is a member of an object in Windows PowerShell.

Hey, Scripting Guy! Question How can I determine if a specific property is actually a member of an object in my Windows PowerShell script?

Hey, Scripting Guy! Answer Use the Get-Member cmdlet, and cast the response into a Boolean data type by using the [bool] type
            accelerator, for example:

[bool](Get-member -Name time -InputObject (get-date) -MemberType Property)

Note  I got this idea from Microsoft PFE, Clint Huffman. He uses it in his PAL data collector. He has a note
in that script that says he got the idea from Jeffery Snover. Cool…

Comments (3)

Skip to main content