MergeHashtable
0.2.1
This module merges two hashtables into one. It is able to handle nested structures like hashtables, arrays and PSCustomObjects. Please see the examples below.
Just use
```PowerShell
$left = [hashtable]@{
"firstname" = "Florian"
"lastname" = "Friedrichs"
"address" = [hashtable]@{
"Street"
This module merges two hashtables into one. It is able to handle nested structures like hashtables, arrays and PSCustomObjects. Please see the examples below.
Just use
```PowerShell
$left = [hashtable]@{
"firstname" = "Florian"
"lastname" = "Friedrichs"
"address" = [hashtable]@{
"Street" = "Kaiserstraße 35"
}
"tags" = [Array]@("nice","company")
"product" = [PSCustomObject]@{
"name" = "Orbit"
"owner" = "Apteco Ltd."
}
}
$right = [hashtable]@{
"lastname" = "von Bracht"
"Street" = "Schaumainkai 87"
"address" = [hashtable]@{
"Street" = "Schaumainkai 87"
"Postcode" = 60596
}
"tags" = [Array]@("wow")
"product" = [PSCustomObject]@{
"sprint" = 106
}
}
Merge-Hashtable -Left $left -right $right -AddKeysFromRight -MergeArrays -MergePSCustomObjects -MergeHashtables
```
to merge two nested hashtables into one where the "right" will overwrite existing values from "left".
Minimum PowerShell version
5.1
Installation Options
Owners
Copyright
(c) 2026 Apteco GmbH. All rights reserved.
Package Details
Author(s)
- florian.von.bracht@apteco.de
Tags
Functions
PSEditions
Dependencies
This module has no dependencies.
Release Notes
0.2.1 Fixed the MergePSCustomObject dependency check using Get-InstalledModule, which only knows about
PowerShellGet-installed modules and misses one that is merely imported into the session (e.g. from
a local path) -- now uses Get-Module so both cases are recognised
0.2.0 New release to 0.2.0 after it is now integrated into AptecoPSFramework module
Fixed another bug with Add-Member and .add()
0.1.2 Fixed a bug where merging ArrayList properties with -MergeArrays used Add-Member instead of adding a real
hashtable key, so the merged key was invisible via indexing/.Keys/ConvertTo-Json on the result
0.1.1 Fixed a problem where values from left were overwritten with empty object from right
0.1.0 First release after running this for a while. Small fix when using [Ordered] in the InputObject
0.0.4 Bumped the copyright year to 2024
0.0.3 Remove dependency for MergePSCustomObject module and add dynamically a message, when it will be needed
0.0.2 Add dependency for MergePSCustomObject module
0.0.1 Initial release of merge hashtable module through psgallery
FileList
- MergeHashtable.nuspec
- MergeHashtable.psd1
- MergeHashtable.psm1
- Public\Merge-Hashtable.ps1