src/Get-cciModule.ps1
function Get-cciModule { [CmdletBinding()] param ( $Name, $destination = 'C:\CCI' ) begin { Write-Verbose "Started running $($MyInvocation.MyCommand)" $cciConnectionParams = Get-cciConnectionParams } process { if ($null -eq (Get-PSRepository -Name $cciConnectionParams.PSRepository_Name -ErrorAction SilentlyContinue)) { $RegisterPSRepositoryParams = @{ "Name" = $cciConnectionParams.PSRepository_Name "SourceLocation" = $cciConnectionParams.PSRepository_SourceLocation "PackageManagementProvider" = $cciConnectionParams.PSRepository_PackageManagementProvider "InstallationPolicy" = $cciConnectionParams.PSRepository_InstallationPolicy } Register-PSRepository @RegisterPSRepositoryParams } if ($null -eq (Get-AzContext)) { Connect-cciAzAccount } if (!(Test-Path $destination)) { New-Item $destination -ItemType Directory } $azStorageAccount = Get-AzStorageAccount $azStorageContainers = $azStorageAccount | Get-AzStorageContainer $azStorageContainerMatches = $azStorageContainers | Where-Object Name -eq $cciConnectionParams.azStorageContainer_Name_Modules $azStorageBlob = $azStorageContainerMatches | Get-AzStorageBlob | Where-Object Name -eq $Name $null = $azStorageBlob | Get-AzStorageBlobContent -Destination $destination } end { Write-Verbose "Finished running $($MyInvocation.MyCommand)" } } |