Functions/Data/Convert-2DArraytoPSObject.ps1
Function Convert-2DArraytoPSobject { [cmdletbinding()] Param ( # Array to Process [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [psobject[]] $Array, # Array Field whose Values should become property names [Parameter(Mandatory=$true)] [String] $NameField, # Array Field whose Values should become propety values [Parameter(Mandatory=$true)] [String] $ValueField ) Begin {$FullArray = [System.Collections.ArrayList]::new()} Process {$Add = $FullArray.Add($Array)} End { $Hash = [ordered]@{Timestamp = get-date} Foreach ($line in $FullArray) { $HASH.Add($Line.$NameField,$Line.$ValueField) } [pscustomobject]($Hash) } } |