@@ -17,57 +17,7 @@ Add-Type -AssemblyName System.IO.Compression.FileSystem
1717$basicAuth = [Convert ]::ToBase64String([Text.Encoding ]::ASCII.GetBytes((" {0}:{1}" -f ' PAT' , $PersonalAccessToken )))
1818$headers = @ { Authorization = (" Basic {0}" -f $basicAuth ) }
1919
20- Function Merge-Objects {
21- <#
22- . SYNOPSIS
23- Merges a PSObject with another PSObject.
24-
25- . DESCRIPTION
26- Iterates through every NoteProperty in the source object.
27- Properties of the source object are added to the target object.
28- If these properties already exist in the target object, they are overwritten.
29- Properties that are PSObjects are merged recursively.
30-
31- . PARAMETER Source
32- The object to merge the target with.
33-
34- . PARAMETER Output
35- The object that the properties of the source are copied into.
36- This object is mutated by the function.
37-
38- . OUTPUTS
39- None
40-
41- . EXAMPLE
42- $source = New-Object PSObject -Property @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D"}
43- $target = New-Object PSObject -Property @{ D = "E", E = "E" }
44-
45- Merge-Objects -Source $source -Target $target
46-
47- $target is now @{ A = "A", B = New-Object PSObject -Property @{ C = "C" }, D = "D", E = "E" }
48- #>
49- param (
50- [PSObject ]$Source ,
51- [PSObject ]$Target
52- )
53-
54- # For each property of the source object, add the property to the target object
55- $Source | `
56- Get-Member - MemberType NoteProperty | `
57- ForEach-Object {
58- $name = $_.Name
59- $value = $Source ." $name "
60- $existingValue = $Target ." $name "
61- if ($_.Definition.StartsWith (" System.Management.Automation.PSCustomObject" ) -and $existingValue -is [PSObject ]) {
62- # If the property is a nested object in both the source and target, merge the nested object in the source with the target object
63- Merge-Objects - Source $value - Target $existingValue
64- } else {
65- # Add the property to the target object
66- # If the property already exists on the target object, overwrite it
67- $Target | Add-Member - MemberType NoteProperty - Name $name - Value $value - Force
68- }
69- }
70- }
20+ Import-Module " $PSScriptRoot \TestUtilities.psm1" - Force
7121
7222# Download the config files--common, per environment, and per region--and merge them into a single file
7323$configObject = New-Object PSObject
0 commit comments