Configurations-AzureImageBuild/ArcGISDownloadInstallers.ps1

Configuration ArcGISDownloadInstallers
{
    param(
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        $Installers,

        [Parameter(Mandatory=$true)]
        [System.Boolean]
        $UseAzureFiles,

        [Parameter(Mandatory=$False)]
        [System.Management.Automation.PSCredential]
        $AFSCredential,

        [Parameter(Mandatory=$false)]
        [System.String]
        $AFSEndpoint,

        [Parameter(Mandatory=$false)]
        [ValidateSet('Absent','Present')] 
        [ValidateNotNullOrEmpty()]
        [string]$Ensure = 'Present'
    )
    
    Import-DscResource -Name ArcGIS_RemoteFile

    Node localhost
    {
        LocalConfigurationManager
        {
            ActionAfterReboot = 'ContinueConfiguration'            
            ConfigurationMode = 'ApplyOnly'    
            RebootNodeIfNeeded = $true
        }

        foreach($Installer in $Installers)
        {
            if($Installer.RemotePath -and $Installer.LocalPath -and $Installer.Name) 
            {
                ArcGIS_RemoteFile $Installer.Name.Replace(' ', '_')
                {
                    Url = $Installer.RemotePath
                    DestinationPath = $ExecutionContext.InvokeCommand.ExpandString($Installer.LocalPath) 
                    UseAzureFiles = if($UseAzureFiles){ $true }else{ $false }
                    AFSEndpoint = if($UseAzureFiles){ $AFSEndpoint }else{ $null }
                    AFSCredential = if($UseAzureFiles){ $AFSCredential }else{ $null }         
                    Ensure = $Ensure
                }

                if((($Installer.Patches).Length -gt 0) -and $Installer.PatchesLocalDir) {
                    foreach($patch in $Installer.Patches){
                        $PatchFileName = Split-Path $patch -leaf
                        ArcGIS_RemoteFile "$($Installer.Name.Replace(' ', '_'))_$($PatchFileName.Replace(' ', '_'))"
                        {
                            Url = $PatchFileName
                            DestinationPath = (Join-Path $ExecutionContext.InvokeCommand.ExpandString($Installer.PatchesLocalDir) $PatchFileName)
                            UseAzureFiles = if($UseAzureFiles){ $true }else{ $false }
                            AFSEndpoint = if($UseAzureFiles){ $AFSEndpoint }else{ $null }
                            AFSCredential = if($UseAzureFiles){ $AFSCredential }else{ $null }         
                            Ensure = $Ensure
                        }
                    }
                }
            }
        }
    }
}