#author("2021-12-16T01:34:55+00:00","default:admin","admin") #author("2021-12-16T01:35:06+00:00","default:admin","admin") -[[PSCustomObject について知りたかったことのすべて:https://docs.microsoft.com/ja-jp/powershell/scripting/learn/deep-dives/everything-about-pscustomobject?view=powershell-7.2]] -[[PowerShellのカスタムオブジェクト(PSCustomObject)の使い方:http://blog.livedoor.jp/morituri/archives/54579410.html]] -[[powershell : PSObject、Hashtable、およびPSCustomObjectの違い:https://www.fixes.pub/program/359919.html]] *結合 [#fe43bc1d] -[[PowerShellでPSCustomObjectに複数のObjectを追加する:https://tech.guitarrapc.com/entry/2013/06/25/230640]] -[[(PowerShell) PSCustomObject をループさせつつキーと値の両方にアクセスする:https://crieit.net/posts/powershell-access-key-and-value-in-psobject-20210112]] -[[ > $obj1 = [PSCustomObject]@{a=1;b=2;c=3} > $obj2 = [PSCustomObject]@{d=4;e=5;f=6} > foreach ($key in $obj1.psobject.properties.name) {Write-Host $key ' = ' $obj1.$key} a = 1 b = 2 c = 3 > foreach ($key in $obj2.psobject.properties.name) {Write-Host $key ' = ' $obj2.$key} d = 4 e = 5 f = 6 > $newObj = New-Object -TypeName PSObject > foreach ($key in $obj1.psobject.properties.name) {$newObj | Add-Member -MemberType NoteProperty -Name $key -Value $obj1.$key} > foreach ($key in $obj2.psobject.properties.name) {$newObj | Add-Member -MemberType NoteProperty -Name $key -Value $obj2.$key} > $newObj | Get-Member | Out-Host -Paging TypeName: System.Management.Automation.PSCustomObject Name MemberType Definition ---- ---------- ---------- Equals Method bool Equals(System.Object obj) GetHashCode Method int GetHashCode() GetType Method type GetType() ToString Method string ToString() a NoteProperty int a=1 b NoteProperty int b=2 c NoteProperty int c=3 d NoteProperty int d=4 e NoteProperty int e=5 f NoteProperty int f=6