Merge-Hashtable¶
SYNOPSIS¶
Merges multiple hashtables, applying overrides in sequence.
SYNTAX¶
__AllParameterSets¶
Merge-Hashtable [-Main] <hashtable> [-Overrides] <hashtable[]> [-Force] [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
This function takes a primary hashtable ($Main
) and merges it with one or more override hashtables ($Overrides
).
Overrides are applied in order, with later values replacing earlier ones if the same key exists.
If the -Force
switch is used, values will be overridden even if they are empty or $null
.
The resulting hashtable is returned.
EXAMPLES¶
EXAMPLE 1¶
$Main = @{ Key1 = 'Value1' Key2 = 'Value2' } $Override1 = @{ Key2 = 'Override2' } $Override2 = @{ Key3 = 'Value3' } $Main | Merge-Hashtable -Overrides $Override1, $Override2
Output:
Name Value
---- -----
Key1 Value1
Key2 Override2
Key3 Value3
Merges $Main
with two override hashtables, applying overrides in order.
EXAMPLE 2¶
$Main = @{ Key1 = 'Value1' Key2 = 'Value2' } $Override = @{ Key2 = '' Key3 = 'Value3' } $Main | Merge-Hashtable -Overrides $Override -Force
Output:
Name Value
---- -----
Key1 Value1
Key2
Key3 Value3
Forces overriding even if the value is empty.
PARAMETERS¶
-Force¶
When specified, force override even if the value is empty or null.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Main¶
Main hashtable
Type: System.Collections.Hashtable
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Overrides¶
Hashtable with overrides. Providing a list of overrides will apply them in order. Last write wins.
Type: System.Collections.Hashtable[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
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.Collections.Hashtable[]¶
{{ Fill in the Description }}
OUTPUTS¶
Hashtable¶
{{ Fill in the Description }}
System.Collections.Hashtable¶
{{ Fill in the Description }}
NOTES¶
A merged hashtable with applied overrides.