Convert-HashtableToString¶
SYNOPSIS¶
Converts a hashtable to its code representation.
SYNTAX¶
Convert-HashtableToString [-Hashtable] <Object> [[-IndentLevel] <Int32>] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
Recursively converts a hashtable to its code representation. This function is useful for exporting hashtables to .psd1 files.
EXAMPLES¶
EXAMPLE 1¶
$hashtable = @{
Key1 = 'Value1'
Key2 = @{
NestedKey1 = 'NestedValue1'
NestedKey2 = 'NestedValue2'
}
Key3 = @(1, 2, 3)
Key4 = $true
}
Convert-HashtableToString -Hashtable $hashtable
This will return the following string: @{ Key1 = 'Value1' Key2 = @{ NestedKey1 = 'NestedValue1' NestedKey2 = 'NestedValue2' } Key3 = @(1, 2, 3) Key4 = $true }
PARAMETERS¶
-Hashtable¶
The hashtable to convert to a string.
Type: Object
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-IndentLevel¶
The indentation level.
Type: Int32
Parameter Sets: (All)
Aliases:
Required: False
Position: 2
Default value: 0
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
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.
INPUTS¶
OUTPUTS¶
NOTES¶
General notes