How can you test if an object has a specific property?

后端 未结 14 908
北恋
北恋 2020-12-25 09:01

How can you test if an object has a specific property?

Appreciate I can do ...

$members = Get-Member -InputObject $myobject 

and th

14条回答
  •  执念已碎
    2020-12-25 10:01

    You can use Get-Member

    if(Get-Member -inputobject $var -name "Property" -Membertype Properties){
    #Property exists
    }
    

提交回复
热议问题