Last active
March 16, 2022 22:16
-
-
Save phatmandrake/73e4dff326776a0a3f0c056ffbf5f9bf to your computer and use it in GitHub Desktop.
Convert a PSCustomObject to a Dictionary/Hashtable
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
class PSHashTable : Collections.Generic.Dictionary[string, string]{ | |
PSHashTable ([PSCustomObject]$Object) { | |
$Object.psobject.properties | ForEach-Object -Process {$this.add($_.name,$Object.($_.name))} | |
} | |
} | |
[HashTable][PSHashTable][PSCustomObject]@{Prop = "val"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment