PoshCode Archive  Artifact [a5703cabe9]

Artifact a5703cabe9b600455a74ce5c297c3923b4f7a2200aa080ded3aacb8fa05b495b:

  • File ConvertFrom-Hashtable.ps1 — part of check-in [d174e9688e] at 2018-06-10 12:56:28 on branch trunk — 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. (user: Joel Bennett size: 921)

# 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: 1118
# x-derived-from-id: 1819
# x-archived: 2017-03-03T08:17:59
# x-published: 2010-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 $output `
	  	-memberType NoteProperty -name $_.Name -value $_.Value }
   $output
}
#}