-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinstall_modules.ps1
More file actions
47 lines (43 loc) · 1.38 KB
/
install_modules.ps1
File metadata and controls
47 lines (43 loc) · 1.38 KB
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
<#
.SYNOPSIS
This script is used to install the required PowerShell Modules for the build process.
It has a dependency on the PowerShell Gallery.
#>
$global:VerbosePreference = 'SilentlyContinue'
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$VerbosePreference = 'SilentlyContinue'
# Fix for PowerShell Gallery and TLS1.2
# https://devblogs.microsoft.com/powershell/powershell-gallery-tls-support/
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
# List of PowerShell Modules required for the build
$modulesToInstall = @(
@{
ModuleName = 'Pester'
ModuleVersion = '5.7.1'
}
@{
ModuleName = 'platyPS'
ModuleVersion = '0.14.2'
}
@{
ModuleName = 'PSScriptAnalyzer'
ModuleVersion = '1.24.0'
}
)
$installModule = @{
Scope = 'CurrentUser'
AllowClobber = $true
Force = $true
SkipPublisherCheck = $true
Verbose = $false
}
foreach ($module in $modulesToInstall) {
try {
Import-Module -Name $module.ModuleName -RequiredVersion $module.ModuleVersion -Force -ErrorAction Stop
}
catch {
Install-Module -Name $module.ModuleName -RequiredVersion $module.ModuleVersion @installModule
Import-Module -Name $module.ModuleName -RequiredVersion $module.ModuleVersion -Force
}
}