1
0
mirror of https://github.com/jaapbrasser/SharedScripts.git synced 2025-12-24 21:51:38 +02:00

Added ConvertTo-FlatObject 🚗

This commit is contained in:
Jaap Brasser
2020-09-10 16:45:24 +02:00
parent c8e46e1f6b
commit 474cab8085

View File

@@ -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