-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCacheModules.ps1
85 lines (69 loc) · 2.85 KB
/
CacheModules.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#Requires -Version 5.1
#Requires -RunAsAdministrator
[CmdletBinding()]
param
(
[Parameter()]
[AllowEmptyString()]
[AllowNull()]
[System.String]
$PackageSourceLocation = $null,
[Parameter()]
[AllowEmptyString()]
[AllowNull()]
[System.String]
$PATToken = $null,
[Parameter(Mandatory)]
[System.String]
$BlobResourceGroup,
[Parameter(Mandatory)]
[System.String]
$BlobStorageAccount,
[Parameter(Mandatory)]
[System.String]
$BlobContainer
)
######## FUNCTIONS ########
try {
Import-Module -Name ".\SupportFunctions.psm1" -ErrorAction Stop
}
catch {
Write-Host "ERROR: Could not load library 'SupportFunctions.psm1'. $($_.Exception.Message.Trim(".")). Exiting." -ForegroundColor Red
exit -1
}
######## SCRIPT VARIABLES ########
$level = 1
$workingDirectory = $PSScriptRoot
$global:progressPreference = "SilentlyContinue"
######## START SCRIPT ########
Write-Log -Message "***********************************************************"
Write-Log -Message "* Starting Caching of Microsoft365DSC Module Dependencies *"
Write-Log -Message "***********************************************************"
Write-Log -Message " "
Write-Log -Message "Switching to path: $workingDirectory" -Level $level
Set-Location -Path $workingDirectory
Write-Log -Message " "
Write-Log -Message "-----------------------------------------------------------"
Write-Log -Message " Checking for presence of Microsoft365DSC module"
Write-Log -Message "-----------------------------------------------------------"
Write-Log -Message " "
$reqVersion = Install-DSCModule
Write-Log -Message " "
Write-Log -Message "-----------------------------------------------------------------------"
Write-Log -Message " Installing generic modules from PSGallery or a custom NuGet repository"
Write-Log -Message "-----------------------------------------------------------------------"
Write-Log -Message " "
Install-GenericModules -PackageSourceLocation $PackageSourceLocation -PATToken $PATToken -Version $reqVersion
Write-Log -Message "Importing module: M365DSCTools" -Level $level
Import-Module -Name M365DSCTools -Force
Write-Log -Message " "
Write-Log -Message "--------------------------------------------------------------------"
Write-Log -Message " Downloading and caching all required modules to Azure Blob Storage"
Write-Log -Message "--------------------------------------------------------------------"
Write-Log -Message " "
Add-ModulesToBlobStorage -ResourceGroupName $BlobResourceGroup -StorageAccountName $BlobStorageAccount -ContainerName $BlobContainer
Write-Log -Message " "
Write-Log -Message "***********************************************************"
Write-Log -Message "* Finished Caching of Microsoft365DSC Module Dependencies *"
Write-Log -Message "***********************************************************"
Write-Log -Message " "