Skip to content

Instantly share code, notes, and snippets.

@Geogboe
Created August 22, 2018 13:06
Show Gist options
  • Save Geogboe/2a491092499dc76a4a6d8217b0c38cf8 to your computer and use it in GitHub Desktop.
Save Geogboe/2a491092499dc76a4a6d8217b0c38cf8 to your computer and use it in GitHub Desktop.
Converts the properties of a PSCustomObject to an ArrayList
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