# encoding: ascii
# api: powershell
# title: ConvertFrom-Hashtable
# description: This script has appeared in many places in many different forms. Eg: PowerShell.com Sometimes it’s called ConvertTo-Object, but I find that too generic, since it can ONLY convert hashtables.
# version: 0.1
# type: function
# author: Joel Bennett
# license: CC0
# function: ConvertFrom-Hashtable
# x-poshcode-id: 1117
# x-derived-from-id: 1118
# x-archived: 2016-11-05T01:07:07
# x-published: 2009-05-20T07:35:00
#
#
# function ConvertFrom-Hashtable {
PARAM([HashTable]$hashtable,[switch]$combine)
BEGIN { $output = New-Object PSObject }
PROCESS {
if($_) {
$hashtable = $_;
if(!$combine) {
$output = New-Object PSObject
}
}
$hashtable.GetEnumerator() |
ForEach-Object { Add-Member -inputObject $object `
-memberType NoteProperty -name $_.Name -value $_.Value }
$object
}
#}