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 { Start-cciCodeFetcher -silent } 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 } } end { Write-Verbose "Finished running $($MyInvocation.MyCommand)" } } |