Created
August 22, 2018 13:06
-
-
Save Geogboe/2a491092499dc76a4a6d8217b0c38cf8 to your computer and use it in GitHub Desktop.
Converts the properties of a PSCustomObject to an ArrayList
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ConvertTo-ArrayList ( [PSCustomObject]$CustomObject ) { | |
$ObjectProperties = $CustomObject.PSObject.Properties | |
$IntermediateHashtable = @{} | |
foreach ( $Property in $ObjectProperties ) { | |
$IntermediateHashtable."$($Property.Name)" = $Property.Value | |
} | |
$ArrayList = [System.Collections.ArrayList]$IntermediateHashtable | |
return , $ArrayList | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment