From 474cab808582ce138ca605e1424d5abb3dcc60cc Mon Sep 17 00:00:00 2001 From: Jaap Brasser Date: Thu, 10 Sep 2020 16:45:24 +0200 Subject: [PATCH] =?UTF-8?q?Added=20ConvertTo-FlatObject=20=F0=9F=9A=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ConvertTo-FlatObject/ConvertTo-FlatObject.ps1 | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 ConvertTo-FlatObject/ConvertTo-FlatObject.ps1 diff --git a/ConvertTo-FlatObject/ConvertTo-FlatObject.ps1 b/ConvertTo-FlatObject/ConvertTo-FlatObject.ps1 new file mode 100644 index 0000000..1d9a5dc --- /dev/null +++ b/ConvertTo-FlatObject/ConvertTo-FlatObject.ps1 @@ -0,0 +1,23 @@ +function ConvertTo-FlatObject { + param( + $sla + ) + + $sla.psobject.properties | ForEach-Object -Begin { + $Hash = [ordered]@{} + } -Process { + if ($_.TypeNameOfValue -ne 'System.Object[]') { + $Hash[$_.Name] = $_.Value + } else { + 'hi' + $CurrentProperty = $_ + $_.Value.psobject.properties | ForEach-Object { + "$($CurrentProperty.Name)$($_.psobject.Name)" + $Hash["$($CurrentProperty.Name)$($_.Name)"] = $_.Value + } + } + } -End { + [pscustomobject]$Hash + } +} +ConvertTo-FlatObject -sla $sla \ No newline at end of file