From a66fb18f9462f1c4cf8d932fc1c0fd6d748fe025 Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 27 Jan 2021 20:15:52 +0100 Subject: [PATCH] Adapt script to 'deployment.type' --- .../ADDS/payload/scripts/09.DNS records.ps1 | 4 ++-- ...ecords.yml => 09.DNS records.secondary.yml} | 0 .../scripts/09.DNS records.standalone.yml | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) rename scripts/ADDS/payload/scripts/{09.DNS records.yml => 09.DNS records.secondary.yml} (100%) create mode 100644 scripts/ADDS/payload/scripts/09.DNS records.standalone.yml diff --git a/scripts/ADDS/payload/scripts/09.DNS records.ps1 b/scripts/ADDS/payload/scripts/09.DNS records.ps1 index 0c46fc2..c332abb 100644 --- a/scripts/ADDS/payload/scripts/09.DNS records.ps1 +++ b/scripts/ADDS/payload/scripts/09.DNS records.ps1 @@ -7,7 +7,7 @@ Param( # Only executed on secondary or standalone Domain Controller If (@('secondary','standalone') -contains $Parameter['deployment.type']) { $GetContentSplat = @{ - Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', '.yml') + Path = "$($PSScriptRoot)\$($MyInvocation.MyCommand)".Replace('.ps1', ".$($Parameter['deployment.type']).yml") Raw = $True } $RawContent = Get-Content @GetContentSplat @@ -20,7 +20,7 @@ If (@('secondary','standalone') -contains $Parameter['deployment.type']) { # Check if the respective .yml file declared substitutions which need to be parsed If (($YamlDocuments.Count -gt 1) -and $YamlDocuments[-1].Variables) { ForEach ($Pattern in $YamlDocuments[-1].Variables) { - $RawContent = $RawContent -replace "\{\{ ($($Pattern.Name)) \}\}", [string](Invoke-Expression -Command $Pattern.Expression) + $RawContent = $RawContent -replace "\{\{ ($($Pattern.Name)) \}\}", [string](Invoke-Expression -Command $Pattern.Expression -ErrorAction 'SilentlyContinue') } # Perform conversion to Yaml again, now with parsed file contents $ConvertFromYamlSplat = @{ diff --git a/scripts/ADDS/payload/scripts/09.DNS records.yml b/scripts/ADDS/payload/scripts/09.DNS records.secondary.yml similarity index 100% rename from scripts/ADDS/payload/scripts/09.DNS records.yml rename to scripts/ADDS/payload/scripts/09.DNS records.secondary.yml diff --git a/scripts/ADDS/payload/scripts/09.DNS records.standalone.yml b/scripts/ADDS/payload/scripts/09.DNS records.standalone.yml new file mode 100644 index 0000000..d9c949f --- /dev/null +++ b/scripts/ADDS/payload/scripts/09.DNS records.standalone.yml @@ -0,0 +1,18 @@ +Entries: +- Name: ldap + Type: A + Value: "{{ primarydc }}" +- Name: timeserver + Type: A + Value: "{{ primarydc }}" +# - Name: mail +# Type: MX +# Value: mail.contoso.com:10 # Value should match pattern ':' +# - Name: voipserver +# Type: SRV +# Value: sip.contoso.com:0:0:5060 # Value should match pattern ':::' +--- +Variables: +- Name: primarydc + Expression: | + (Resolve-DnsName -Name $Parameter['addsconfig.domainname'] | Sort-Object)[0].IPAddress