ConvertTo-HashTable
SYNOPSIS
Convert a PSCustomObject to a hashtable.
SYNTAX
ConvertTo-HashTable [-Object] <PSObject[]> [-RemoveNullOrEmpty] [-ReplaceNullWithEmpty] [<CommonParameters>]
DESCRIPTION
This function converts a PSCustomObject (or an array of PSCustomObjects) into a hashtable. It provides options to remove null or empty values and to replace null values with empty strings.
EXAMPLES
EXAMPLE 1
PS C:\> ConvertTo-HashTable -Object $Object Converts the PSCustomObject into a hashtable, including all properties.
EXAMPLE 2
PS C:\> ConvertTo-HashTable -Object $Object -RemoveNullOrEmpty Converts the PSCustomObject into a hashtable, excluding properties with null or empty values.
EXAMPLE 3
PS C:\> ConvertTo-HashTable -Object $Object -ReplaceNullWithEmpty Converts the PSCustomObject into a hashtable, replacing null values with empty strings.
PARAMETERS
-Object
The PSCustomObject (or array of PSCustomObjects) to be converted into a hashtable.
Type: PSObject[]
Parameter Sets: (All)
Aliases: PSCustomObject, PSObject
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
-RemoveNullOrEmpty
A switch to remove properties with null or empty values from the resulting hashtable.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ReplaceNullWithEmpty
A switch to replace null values with empty strings in the resulting hashtable.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.