ConvertTo-Hashtable¶
SYNOPSIS¶
Converts an object to a hashtable.
SYNTAX¶
__AllParameterSets¶
ConvertTo-Hashtable [-InputObject] <psobject> [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
Recursively converts an object to a hashtable. This function is useful for converting complex objects to hashtables for serialization or other purposes.
EXAMPLES¶
EXAMPLE 1¶
$object = [PSCustomObject]@{ Name = 'John Doe' Age = 30 Address = [PSCustomObject]@{ Street = '123 Main St' City = 'Somewhere' ZipCode = '12345' } Occupations = @( [PSCustomObject]@{ Title = 'Developer' Company = 'TechCorp' }, [PSCustomObject]@{ Title = 'Consultant' Company = 'ConsultCorp' } ) } ConvertTo-Hashtable -InputObject $object
Output:
Name Value
---- -----
Age 30
Address {[ZipCode, 12345], [City, Somewhere], [Street, 123 Main St]}
Name John Doe
Occupations {@{Title=Developer; Company=TechCorp}, @{Title=Consultant; Company=ConsultCorp}}
This returns a hashtable representation of the object.
PARAMETERS¶
-InputObject¶
The object to convert to a hashtable.
Type: System.Management.Automation.PSObject
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters¶
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS¶
System.Management.Automation.PSObject¶
{{ Fill in the Description }}
OUTPUTS¶
hashtable¶
{{ Fill in the Description }}
System.Collections.Hashtable¶
{{ Fill in the Description }}
NOTES¶
The function returns a hashtable representation of the input object, converting complex nested structures recursively.