templates/mgmt-1.template.yaml [430:542]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                      } Catch [System.Exception] {
                          Write-Output "Failed to read and download $CustomModule.Name from S3 $_"
                          Exit 1
                      }
                  }

                  Write-Output 'Installing NuGet Package Provider'
                  Try {
                      $Null = Install-PackageProvider -Name 'NuGet' -MinimumVersion '2.8.5' -Force -ErrorAction Stop
                  } Catch [System.Exception] {
                      Write-Output "Failed to install NuGet Package Provider $_"
                      Exit 1
                  }

                  Write-Output 'Setting PSGallery Respository to trusted'
                  Try {
                      Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted' -ErrorAction Stop
                  } Catch [System.Exception] {
                      Write-Output "Failed to set PSGallery Respository to trusted $_"
                      Exit 1
                  }

                  Write-Output 'Installing the needed Powershell DSC modules for this Quick Start'
                  Foreach ($Module in $Modules) {
                      Try {
                          Install-Module -Name $Module.Name -RequiredVersion $Module.Version -ErrorAction Stop
                      } Catch [System.Exception] {
                          Write-Output "Failed to Import Modules $_"
                          Exit 1
                      }
                  } 
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: configureInstance
          - name: configureInstance
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  New-VolumeFromRawDisk
                  Invoke-PreConfig
                  Invoke-LcmConfig
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: configureMgmtMof
          - name: configureMgmtMof
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  $EniConfig = Get-EniConfig
                  $AltSecret = Get-SecretInfo -Domain '{{DomainNetBIOSName}}' -SecretArn '{{AdministratorSecret}}'
                  Set-DscConfiguration -DaCredentials $AltSecret.DomainCredentials -DeploymentType 'MemberServer' -DomainDNSName '{{DomainDNSName}}' -DomainNetBIOSName '{{DomainNetBIOSName}}' -ExistingDcIP01 '{{DomainController1IP}}' -ExistingDcIP02 '{{DomainController2IP}}' -GatewayAddress $EniConfig.GatewayAddress -InstanceIP $EniConfig.IpAddress -InstanceNetBIOSName '{{MgmtServerNetBIOSName}}' -MacAddress $EniConfig.MacAddress
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: runMgmtMof
          - name: runMgmtMof
            action: aws:runCommand
            onFailure: step:signalfailure
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  Start-DscConfiguration 'C:\AWSQuickstart\ConfigInstance' -Wait -Verbose -Force
                  Invoke-DscStatusCheck
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: PostConfig
          - name: PostConfig
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  Set-MgmtPostConfig -DirectoryID '{{DirectoryID}}' -VPCCIDR '{{VPCCIDR}}'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



templates/workshop/mgmt-1.template.yaml [407:519]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                      } Catch [System.Exception] {
                          Write-Output "Failed to read and download $CustomModule.Name from S3 $_"
                          Exit 1
                      }
                  }

                  Write-Output 'Installing NuGet Package Provider'
                  Try {
                      $Null = Install-PackageProvider -Name 'NuGet' -MinimumVersion '2.8.5' -Force -ErrorAction Stop
                  } Catch [System.Exception] {
                      Write-Output "Failed to install NuGet Package Provider $_"
                      Exit 1
                  }

                  Write-Output 'Setting PSGallery Respository to trusted'
                  Try {
                      Set-PSRepository -Name 'PSGallery' -InstallationPolicy 'Trusted' -ErrorAction Stop
                  } Catch [System.Exception] {
                      Write-Output "Failed to set PSGallery Respository to trusted $_"
                      Exit 1
                  }

                  Write-Output 'Installing the needed Powershell DSC modules for this Quick Start'
                  Foreach ($Module in $Modules) {
                      Try {
                          Install-Module -Name $Module.Name -RequiredVersion $Module.Version -ErrorAction Stop
                      } Catch [System.Exception] {
                          Write-Output "Failed to Import Modules $_"
                          Exit 1
                      }
                  } 
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: configureInstance
          - name: configureInstance
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  New-VolumeFromRawDisk
                  Invoke-PreConfig
                  Invoke-LcmConfig
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: configureMgmtMof
          - name: configureMgmtMof
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  $EniConfig = Get-EniConfig
                  $AltSecret = Get-SecretInfo -Domain '{{DomainNetBIOSName}}' -SecretArn '{{AdministratorSecret}}'
                  Set-DscConfiguration -DaCredentials $AltSecret.DomainCredentials -DeploymentType 'MemberServer' -DomainDNSName '{{DomainDNSName}}' -DomainNetBIOSName '{{DomainNetBIOSName}}' -ExistingDcIP01 '{{DomainController1IP}}' -ExistingDcIP02 '{{DomainController2IP}}' -GatewayAddress $EniConfig.GatewayAddress -InstanceIP $EniConfig.IpAddress -InstanceNetBIOSName '{{MgmtServerNetBIOSName}}' -MacAddress $EniConfig.MacAddress
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: runMgmtMof
          - name: runMgmtMof
            action: aws:runCommand
            onFailure: step:signalfailure
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  Start-DscConfiguration 'C:\AWSQuickstart\ConfigInstance' -Wait -Verbose -Force
                  Invoke-DscStatusCheck
              CloudWatchOutputConfig:
                CloudWatchOutputEnabled: true
                CloudWatchLogGroupName: !Sub /aws/Quick_Start/${AWS::StackName}
            nextStep: PostConfig
          - name: PostConfig
            action: aws:runCommand
            inputs:
              DocumentName: AWS-RunPowerShellScript
              InstanceIds:
                - '{{mgmtInstanceId.InstanceId}}'
              Parameters:
                commands: |-
                  Try {
                      Import-Module -Name 'C:\AWSQuickstart\Module-AD\Module-AD.psm1' -Force
                  } Catch [System.Exception] {
                      Write-Output "Failed to import AD PS Module $_"
                      Exit 1
                  }
                  Set-MgmtPostConfig -DirectoryID '{{DirectoryID}}' -VPCCIDR '{{VPCCIDR}}'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



