-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStart-HCCDeploy.ps1
More file actions
226 lines (200 loc) · 8.21 KB
/
Start-HCCDeploy.ps1
File metadata and controls
226 lines (200 loc) · 8.21 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
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# Call this script with
# iex (irm https://tinyurl.com/HCCDeploy)
# Utilizing David Segura's functions
iex (irm sandbox.osdcloud.com)
# David stores the state of the computer in $WindowsPhase, i.e. the computer is
# booted to WinPe, at OOBE, or within Windows, etc.
# David has several useful functions built into sandbox.osdcloud.com, which
# is called from functions.osdcloud.com. We will utilize some of these.
# https://www.osdcloud.com/sandbox/functions
# AddCapability
# NetFX
# RemoveAppx
# Rsat
# UpdateDrivers
# UpdateWindows
function Get-M365Config {
[CmdletBinding()]
param (
[Parameter()]
[string]
$Destination
)
$config = @'
<Configuration ID="d9bd8d5c-adaa-4cf1-a70d-659fa1450f72">
<Info Description="Standard User Deployment" />
<Add OfficeClientEdition="64" Channel="MonthlyEnterprise" MigrateArch="TRUE">
<Product ID="O365ProPlusRetail">
<Language ID="en-us" />
<ExcludeApp ID="Groove" />
<ExcludeApp ID="Lync" />
<ExcludeApp ID="Bing" />
</Product>
</Add>
<Property Name="SharedComputerLicensing" Value="1" />
<Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
<Property Name="DeviceBasedLicensing" Value="0" />
<Property Name="SCLCacheOverride" Value="0" />
<Property Name="TenantId" Value="6c031f94-c402-433a-92d2-2d3ce8516da3" />
<Updates Enabled="TRUE" />
<RemoveMSI>
<IgnoreProduct ID="InfoPath" />
<IgnoreProduct ID="InfoPathR" />
<IgnoreProduct ID="PrjPro" />
<IgnoreProduct ID="PrjStd" />
<IgnoreProduct ID="SharePointDesigner" />
<IgnoreProduct ID="VisPro" />
<IgnoreProduct ID="VisStd" />
</RemoveMSI>
<AppSettings>
<Setup Name="Company" Value="Hillsborough Community College" />
</AppSettings>
<Display Level="Full" AcceptEULA="TRUE" />
</Configuration>
'@
$config | out-file "$Destination"
}
function InstallSoftware {
$Destination = $env:temp
Get-M365Config -destination "$Destination\m365config.xml"
$Software = @(
@{
Name = "Google Chrome"
URI = "https://dl.google.com/dl/chrome/install/googlechromestandaloneenterprise64.msi"
Parameters = "/i googlechromestandaloneenterprise64.msi /qn"
},
@{
Name = "Microsoft 365 Apps"
URI = "https://officecdn.microsoft.com/pr/wsus/setup.exe"
Parameters = "/configure $Destination\m365config.xml"
}
)
foreach ( $app in $Software) {
$WebClient = New-Object System.Net.WebClient
$FileName = $app.URI.Substring($app.URI.LastIndexOf('/')+1)
$WebClient.DownloadFile($app.URI,"$Destination\$FileName")
$Ext = $FileName.Substring($FileName.LastIndexOf('.')+1)
cd $Destination
switch ($Ext) {
"msi" {
Start-Process msiexec.exe -ArgumentList $app.Parameters -Wait
}
"exe" {
Start-Process $FileName -ArgumentList $app.Parameters -Wait
}
}
}
}
function ChoiceMenu {
param(
[String]$Title,
[String]$Message,
[String[]]$Options,
[Int]$Default=0
)
$Answers = @()
foreach ($Answer in $Options) {
$Answers += New-Object System.Management.Automation.Host.ChoiceDescription "&$Answer", $Answer
}
# $Academic = New-Object System.Management.Automation.Host.ChoiceDescription '&Academic', 'Academic.hccfl.edu'
# $Family = New-Object System.Management.Automation.Host.ChoiceDescription '&Family', 'Family.hccfl.edu'
# $None = New-Object System.Management.Automation.Host.ChoiceDescription '&None', 'Do not join.'
switch ($Answers.count) {
0 { Write-Error "You must enter an answer option." }
1 { Write-Error "You must enter more than 1 answer option."}
2 { $OptionObj = [System.Management.Automation.Host.ChoiceDescription[]]($Answers[0], $Answers[1]) }
3 { $OptionObj = [System.Management.Automation.Host.ChoiceDescription[]]($Answers[0], $Answers[1], $Answers[2]) }
4 { $OptionObj = [System.Management.Automation.Host.ChoiceDescription[]]($Answers[0], $Answers[1], $Answers[2], $Answers[3]) }
5 { Write-Error "Only 4 options are allowed."}
Default {5}
}
# $OptionObj = [System.Management.Automation.Host.ChoiceDescription[]]($Academic, $Family, $None)
# $title = 'Domain'
# $message = 'Which domain would you join?'
$result = $host.ui.PromptForChoice($title, $message, $OptionObj, $Default)
$result
}
function TryDomainJoin {
[CmdletBinding()]
param (
[Parameter()]
[String]
$Domain,
$ComputerName
)
$Credential = Get-Credential -Message "Enter your domain credentials to join. ( $domain\<username> )"
try {
Rename-Computer $ComputerName
Write-Host -ForegroundColor White -BackgroundColor DarkMagenta "Joining $Domain"
Add-Computer -Domain $Domain -NewName $ComputerName -Credential $Credential -Restart -Force
}
catch {
Write-Error $_.Exception.Message
}
}
function DoCustomizations {
AddCapability -Name "Print.Management*"
RemoveAppx people,xbox,phone,GamingApp
NetFX
UpdateDrivers
UpdateWindows
}
Switch ($WindowsPhase) {
"WinPE" {
Start-OSDCloud -OSName 'Windows 10 21H2 x64' -OSEdition Enterprise -OSLanguage en-us -OSLicense Volume -Restart
}
"OOBE" {
if ($Global:RegAutoPilot.CloudAssignedForcedEnrollment -eq 1) {
Write-Host -ForegroundColor Yellow "Press enter to Proceed with Autopilot. Otherwise, power off the machine and ask your administrator to deregister this device from Autopilot if necessary."
pause
Write-Host -ForegroundColor DarkGray "Proceeding with Windows Autopilot."
Write-Host -ForegroundColor Cyan "Specify a computer name. The rename will not complete until rebooted."
$ComputerName = Read-Host "Computer Name"
DoCustomizations
if ($ComputerName) {
Write-Host -ForegroundColor Cyan "The device is ready for provisiong with Windows Autopilot. Press enter to reboot, completing the device rename and continue through OOBE."
Rename-Computer $ComputerName -Force -Restart
}
}
else {
Write-Host -ForegroundColor Cyan "This device does not have an Autopilot Profile. Choose 'Azure AD' to begin registering the device with Autopilot."
$Options = "Azure AD", "Family.hccfl.edu", "Academic.hccfl.edu", "None"
$Result = ChoiceMenu -Title "Domain to Join:" -Message "Azure AD should be chosen most of the time." -Options $Options -Default 3
Write-Host -ForegroundColor Cyan "Specify the computer name."
$ComputerName = Read-Host "Computer Name"
switch ($Result) {
0 {
if ($ComputerName) {
Rename-Computer $ComputerName -Force
}
DoCustomizations
iex ( iwr https://raw.githubusercontent.com/JaredSeavyHodge/APEnroller/master/AutoPilot_Register.ps1 -UseBasicParsing )
}
1 {
Write-Output "Preparing the computer for on-prem AD join."
Write-Output "Installing Software"
InstallSoftware
DoCustomizations
TryDomainJoin -ComputerName $ComputerName -Domain "family.hccfl.edu"
}
2 {
Write-Output "Preparing the computer for on-prem AD join."
Write-Output "Installing Software"
InstallSoftware
DoCustomizations
TryDomainJoin -ComputerName $ComputerName -Domain "academic.hccfl.edu"
}
3 {
Write-Warning "Not joining a domain. Renaming the computer and rebooting."
if ($ComputerName) {
DoCustomizations
Rename-Computer $ComputerName -Force -Restart
}
}
}
}
}
"Windows" {
# DoCustomizations
}
}