-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ps1
209 lines (200 loc) · 6.41 KB
/
configure.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# WVD Script Parameters #
##############################
Param (
[Parameter(Mandatory=$true)]
[string]$RegistrationToken,
[string]$ProfilePath,
[string]$aadjoin,
[string]$localadmin
)
# WVD Variables #
$LocalWVDpath = "c:\temp\wvd\"
$WVDBootURI = 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrxrH'
$WVDAgentURI = 'https://query.prod.cms.rt.microsoft.com/cms/api/am/binary/RWrmXv'
$WVDAgentInstaller = 'WVD-Agent.msi'
$WVDBootInstaller = 'WVD-Bootloader.msi'
$aadjoin = [System.Convert]::ToBoolean($aadjoin)
#create directory
if((Test-Path c:\temp) -eq $false) {
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Create C:\temp Directory"
Write-Host `
-ForegroundColor Cyan `
-BackgroundColor Black `
"creating temp directory"
New-Item -Path c:\temp -ItemType Directory
}
else {
Add-Content -LiteralPath C:\New-WVDSessionHost.log "C:\temp Already Exists"
Write-Host `
-ForegroundColor Yellow `
-BackgroundColor Black `
"temp directory already exists"
}
if((Test-Path $LocalWVDpath) -eq $false) {
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Create C:\temp\WVD Directory"
Write-Host `
-ForegroundColor Cyan `
-BackgroundColor Black `
"creating c:\temp\wvd directory"
New-Item -Path $LocalWVDpath -ItemType Directory
}
else {
Add-Content -LiteralPath C:\New-WVDSessionHost.log "C:\temp\WVD Already Exists"
Write-Host `
-ForegroundColor Yellow `
-BackgroundColor Black `
"c:\temp\wvd directory already exists"
}
New-Item -Path c:\ -Name New-WVDSessionHost.log -ItemType File
Add-Content `
-LiteralPath C:\New-WVDSessionHost.log `
"
ProfilePath = $ProfilePath
RegistrationToken = $RegistrationToken
"
#download wvd components
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Downloading WVD Boot Loader"
Invoke-WebRequest -Uri $WVDBootURI -OutFile "$LocalWVDpath$WVDBootInstaller"
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Downloading WVD Agent"
Invoke-WebRequest -Uri $WVDAgentURI -OutFile "$LocalWVDpath$WVDAgentInstaller"
# Install WVD Componants #
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Installing WVD Bootloader"
$bootloader_deploy_status = Start-Process `
-FilePath "msiexec.exe" `
-ArgumentList "/i $LocalWVDpath$WVDBootInstaller", `
"/quiet", `
"/qn", `
"/norestart", `
"/passive", `
"/l* $LocalWVDpath\AgentBootLoaderInstall.txt" `
-Wait `
-Passthru
$sts = $bootloader_deploy_status.ExitCode
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Installing WVD Bootloader Complete"
Write-Output "Installing RDAgentBootLoader on VM Complete. Exit code=$sts`n"
Wait-Event -Timeout 5
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Installing WVD Agent"
Write-Output "Installing RD Infra Agent on VM $AgentInstaller`n"
$agent_deploy_status = Start-Process `
-FilePath "msiexec.exe" `
-ArgumentList "/i $LocalWVDpath$WVDAgentInstaller", `
"/quiet", `
"/qn", `
"/norestart", `
"/passive", `
"REGISTRATIONTOKEN=$RegistrationToken", "/l* $LocalWVDpath\AgentInstall.txt" `
-Wait `
-Passthru
Add-Content -LiteralPath C:\New-WVDSessionHost.log "WVD Agent Install Complete"
Wait-Event -Timeout 5
# Enable Screen Capture Protection #
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Enable Screen Capture Protection"
Push-Location
Set-Location "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Terminal Services"
New-ItemProperty `
-Path .\ `
-Name fEnableScreenCaptureProtection `
-Value "1" `
-PropertyType DWord `
-Force
Pop-Location
#######################################
# FSLogix User Profile Settings #
#######################################
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Configure FSLogix Profile Settings"
Push-Location
Set-Location HKLM:\SOFTWARE\
New-Item `
-Path HKLM:\SOFTWARE\FSLogix `
-Name Profiles `
-Force
New-Item `
-Path HKLM:\Software\FSLogix\Profiles\ `
-Name Apps `
-Force
Set-ItemProperty `
-path HKLM:\Software\FSLogix\Apps `
-name "CleanupInvalidSessions" `
-type "Dword" `
-value "1" `
-force
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "Enabled" `
-Type "Dword" `
-Value "1"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "VHDLocations" `
-Value "$ProfilePath\Profiles" `
-Type MultiString `
-Force
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "SizeInMBs" `
-Type "Dword" `
-Value "30000"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "IsDynamic" `
-Type "Dword" `
-Value "1"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "VolumeType" `
-Type String `
-Value "vhdx"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "FlipFlopProfileDirectoryName" `
-Type "Dword" `
-Value "1"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "SIDDirNamePattern" `
-Type String `
-Value "%username%%sid%"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "SIDDirNameMatch" `
-Type String `
-Value "%username%%sid%"
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "DeleteLocalProfileWhenVHDShouldApply" `
-Type DWord `
-Value 1
New-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "PreventLoginWithFailure" `
-Value "1" `
-PropertyType "DWORD" `
-Force
Set-ItemProperty `
-Path HKLM:\Software\FSLogix\Profiles `
-Name "RedirXMLSourceFolder" `
-Value "$profilepath\FSLogixRules" `
-Type string `
-Force
Pop-Location
Add-LocalGroupMember -Group "FSLogix Profile Exclude List" -member $localadmin -verbose
##############################
# Enable Azure AD Join #
##############################
if ($aadjoin){
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Enable Azure AD Join"
Push-Location
Set-Location HKLM:\SOFTWARE\Microsoft
#New-Item `
# -Path HKLM:\SOFTWARE\Microsoft `
# -Name RDInfraAgent `
# -Force
New-Item `
-Path HKLM:\Software\Microsoft\RDInfraAgent `
-Name AADJPrivate `
-Force
Pop-Location
}
# Restart Computer #
Add-Content -LiteralPath C:\New-WVDSessionHost.log "Process Complete - REBOOT"
Restart-Computer -Force