How to create new clone instance of PSObject object

前端 未结 9 661
野趣味
野趣味 2020-12-09 02:20

I want to create new instance of my custom PSObject. I have a Button object created as PSObject and I want to create new object Button2 which has the same members as Button

9条回答
  •  时光说笑
    2020-12-09 03:08

    Another possibility:

     $o1 = New-Object PsObject -Property @{ prop1='a' ; prop2='b' }
     $o2 = $o1 | select *
     $o2.prop1 = 'newvalue'
     $o1.prop1
     $o2.prop1
     a
     newvalue
    

提交回复
热议问题