function ConvertTo-Hash { <# .SYNOPSIS Helper to turn some object into a viable Hash .PARAMETER DynamicObject A dynamic object to convert the properties from #> [CmdletBinding()] Param( [Parameter(Mandatory=$True, ValueFromPipeline=$True)] [object]$DynamicObject ) $logLead = (Get-LogLeadName) Write-Warning "$logLead : You probably don't want this function (do you want ConvertTo-Hashtable instead), but that's your call I guess" $returnValue = @{} foreach ($property in $DynamicObject.PSObject.Properties) { $returnValue[$property.Name] = $property.Value } return $returnValue }