Skip to content

Instantly share code, notes, and snippets.

@dlwyatt
Created March 5, 2015 14:40
Show Gist options
  • Save dlwyatt/4166704557cf73bdd3ae to your computer and use it in GitHub Desktop.
Save dlwyatt/4166704557cf73bdd3ae to your computer and use it in GitHub Desktop.
ConvertTo-Hashtable
function ConvertTo-Hashtable
{
[CmdletBinding()]
param (
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[psobject[]] $InputObject
)
process
{
foreach ($object in $InputObject)
{
$hash = @{}
foreach ($property in $object.PSObject.Properties)
{
$hash[$property.Name] = $property.Value
}
$hash
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment