-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path00 Prep.ps1
79 lines (70 loc) · 2.52 KB
/
00 Prep.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
$requiredModules = @{
VSTeam = '7.15.2'
AutomatedLab = 'latest'
}
foreach ($module in $requiredModules.GetEnumerator())
{
$param = @{
Name = $module.Name
Scope = 'AllUsers'
Force = $true
AllowClobber = $true
SkipPublisherCheck = $true
}
if ($module.Value -ne 'latest')
{
$param.RequiredVersion = $module.Value
}
$moduleInfo = Get-Module -Name $module.Name -ListAvailable
if ($module.Value -ne 'latest')
{
$moduleInfo = $moduleInfo | Where-Object Version -EQ $module.Value
}
if (-not ($moduleInfo))
{
Write-Host "Installing module '$($module.Name)' with version '$($module.Value)'"
Install-Module @param
}
else
{
Write-Host "Module '$($module.Name)' with version '$($module.Value)' is already installed"
}
}
Write-Host 'Installing the Azure modules for AutomatedLab...' -NoNewline
Install-LabAzureRequiredModule -Scope AllUsers
Write-Host done.
if (-not (Test-LabAzureModuleAvailability))
{
Write-Host 'Azure modules for AutomatedLab are still not available. Please restart the script.'
return
}
Write-Host '------------------------------------------------------------' -ForegroundColor Magenta
Write-Host 'PowerShell may exit during the next step. If it does, please restart the script.' -ForegroundColor Magenta
Write-Host '------------------------------------------------------------' -ForegroundColor Magenta
Write-Host 'Enabling remoting for the lab hosts...' -NoNewline
if (-not (Test-LabHostRemoting))
{
Enable-LabHostRemoting
}
Write-Host done.
if (-not (Test-LabHostRemoting))
{
Write-Host 'Remoting for the lab hosts is still not enabled. Please restart the script.'
return
}
if ($null -eq (git config --global user.email))
{
$emailAddress = Read-Host -Prompt 'The git user email is not set. Please enter your email address'
git config --global user.email $emailAddress
$yourName = Read-Host -Prompt 'The git user name is not set. Please enter your / a name'
git config --global user.name $yourName
}
else
{
Write-Host 'Git user email and name are already set.'
}
Write-Host 'Disabling web account manager login for Azure.'
Set-AzConfig -EnableLoginByWam $false | Out-Null
Set-AzConfig -DisplaySecretsWarning $false | Out-Null
Set-Item -Path Env:\AZURE_CLIENTS_SHOW_SECRETS_WARNING -Value $false
Write-Host 'The preparation is done. You can now continue with the next steps.'