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

PowerTip: Determine if Property is Member of Object

$
0
0

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…


Viewing all articles
Browse latest Browse all 3333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>