PoshCode Archive  Artifact [49602cab40]

Artifact 49602cab403f599737f8ddec5fe7066831861c5b9fe428129a2e10eb08fe57ed:

  • File ConvertFrom-Hashtable.ps1 — part of check-in [38212d2b59] 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: 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
}
#}