Last active
November 26, 2019 15:23
-
-
Save kpatnayakuni/8af168af4dabfebc1bf6cc4df50f6d96 to your computer and use it in GitHub Desktop.
Converts Object properties into HashTable
This file contains hidden or 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
| # Converts Object properties to HashTable. | |
| Function Convert-ObjectToHashTable | |
| { | |
| [CmdletBinding()] | |
| param | |
| ( | |
| [parameter(Mandatory=$true,ValueFromPipeline=$true)] | |
| [pscustomobject] $Object | |
| ) | |
| $HashTable = @{} | |
| $ObjectMembers = Get-Member -InputObject $Object -MemberType *Property | |
| foreach ($Member in $ObjectMembers) | |
| { | |
| $HashTable.$($Member.Name) = $Object.$($Member.Name) | |
| } | |
| return $HashTable | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment