src/Get-cciModule.ps1

function Get-cciModule {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)]
        $Name,
        $destination = 'C:\CCI',
        [switch] $NoClobber
    )
    begin {
        Write-Verbose "Started running $($MyInvocation.MyCommand)"
        $GetModuleAz = Get-Module Az.*
        $cciConnectionParams = Get-cciConnectionParams
    }
    process {
        if (('Az.Storage' -in $GetModuleAz.Name) -and ('Az.Keyvault' -in $GetModuleAz.Name)) {
            Write-Verbose "Prerequisite modules are present. Continuing."
        }
        else {
            Install-Module -Name Az.Storage -RequiredVersion 4.9.0 # Oct 2022 - 4.10.0 is bad, so forcing version 4.5.0
            #Install-Module Az.Storage -Force
            Install-Module Az.Keyvault -Force
        }
        if ($null -eq (Get-AzContext)) {
            Connect-cciAzAccount
        }
        if (!(Test-Path $destination)) {
            New-Item $destination -ItemType Directory
        }
        if (!($NoClobber)) {
            Remove-Item -Path "$($destination)\$($name)" -Recurse -Force -ErrorAction SilentlyContinue
            $azStorageAccount = Get-AzStorageAccount
            $azStorageContainers = $azStorageAccount | Get-AzStorageContainer
            $azStorageContainerMatches = $azStorageContainers | Where-Object Name -eq $cciConnectionParams.azStorageContainer_Name_Modules
            $azStorageBlob = $azStorageContainerMatches | Get-AzStorageBlob -Prefix $Name
            $null = $azStorageBlob | Get-AzStorageBlobContent -Destination $destination
        }
        Publish-CciCustomizationBats -moduleName $name
    }
    end {
        Write-Verbose "Finished running $($MyInvocation.MyCommand)"
    }
}