-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnboardingScript.ps1
More file actions
69 lines (57 loc) · 2.12 KB
/
Copy pathOnboardingScript.ps1
File metadata and controls
69 lines (57 loc) · 2.12 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
# Get CDN url
$cdn = $env:OfficeCDN
# Set local support account's password to never expire
Set-LocalUser -Name "Support" -PasswordNeverExpires:$true
# Set time zone to Eastern Standard Time
if((Get-TimeZone).Id -ne ("Eastern Standard Time") ) {
Set-TimeZone -Name "Eastern Standard Time"
}
# Set computer to never sleep when plugged in
powercfg -change -standby-timeout-ac 0
# Add bloatware here
$bloatware = @(
'Microsoft.Xbox.TCUI'
'Microsoft.XboxGamingOverlay'
'Microsoft.XboxGameOverlay'
'Microsoft.XboxIdentityProvider'
'Microsoft.XboxSpeechToTextOverlay'
'Microsoft.GamingApp'
'Microsoft.ZuneMusic'
'Microsoft.ZuneVideo'
'Microsoft.BingNews'
'Microsoft.BingWeather'
'AD2F1837.HPDesktopSupportUtilities'
'AppUp.IntelGraphicsExperience'
'AppUp.IntelManagementandSecurityStatus'
'RealtekSemiconductorCorp.HPAudioControl'
)
# Remove bloatware
foreach ($app in $bloatware) {
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers
Get-AppxProvisionedPackage -Online | where {$_.DisplayName -like $app} | Remove-AppxProvisionedPackage -Online
}
# Install office if a CDN link is provided
if($cdn -ne $null) {
try {
$webClient = New-Object System.Net.WebClient
# Use temp folder
$tempFolder = [System.IO.Path]::GetTempPath()
$destination = Join-Path -Path $tempFolder -ChildPath "Office.img"
$webClient.DownloadFile($cdn, $destination)
# Mount the image
$mountResult = Mount-DiskImage -ImagePath $destination -PassThru
$driveLetter = ($mountResult | Get-Volume).DriveLetter
# Start Setup.exe
Start-Process -FilePath "Setup.exe" -WorkingDirectory "$($driveLetter):\" -Wait
# Dismount image
Dismount-DiskImage -ImagePath $destination
# Clean up temp folder
Remove-Item -Path $destination
}
catch [System.Net.WebException],[System.IO.IOException] {
Write-Error "Unable to download Microsoft Office from $($cdn)"
}
catch {
Write-Error "An unresolved error occurred"
}
}