-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathInstall-Windows11.ps1
More file actions
56 lines (51 loc) · 2.68 KB
/
Copy pathInstall-Windows11.ps1
File metadata and controls
56 lines (51 loc) · 2.68 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
<#PSScriptInfo
.VERSION 1.1
.GUID 1db3a669-88dc-44fd-a9cb-8d029702be66
.AUTHOR takescake@outlook.com
.TAGS
Windows 11
Windows Upgrade
Automation
.LICENSEURI https://github.com/CakeRepository/Install-Windows11/blob/main/LICENSE
.PROJECTURI https://github.com/CakeRepository/Install-Windows11
.RELEASENOTES
1.1 - Updated URI's for project
#>
<#
.DESCRIPTION
Downloads the Windows 11 ISO from the any URL hosting it, mounts it to the Windows Operating system, and then attempts to install it will fail if it doesn't meet the strict Windows 11 requirements.
.PARAMETER arguments
These are the arguments to give to the Windows 11 setup.exe after it is mounted.
These switches can be found here - https://docs.microsoft.com/en-us/windows-hardware/manufacture/desktop/windows-setup-command-line-options
Default: /auto upgrade /DynamicUpdate Disable /quiet
.PARAMETER DownloadPath
The path where the Windows 11 ISO will be downloaded.
Default: C:\windows\temp\win11.iso
.PARAMETER DownloadURL
The URL for the Windows 11 ISO you can grab a download link here https://www.microsoft.com/en-us/software-download/windows11 that lasts for 24 hours
.EXAMPLE
Install-Windows11 -DownloadURL "https://software-download.microsoft.com/pr/Win11_English_x64.iso?t=91df36a5-c6e0-46b5-8ad8-960c29aae6a4&e=1634707003&h=1f1e014b5f7389e51b98958c9c2d0949"
Install-Windows11 -arguments "/auto upgrade /DynamicUpdate Disable" -DownloadURL "https://software-download.microsoft.com/pr/Win11_English_x64.iso?t=91df36a5-c6e0-46b5-8ad8-960c29aae6a4&e=1634707003&h=1f1e014b5f7389e51b98958c9c2d0949"
Install-Windows11 -DownloadPath "C:\temp\win11.iso" `
-DownloadURL "https://software-download.microsoft.com/pr/Win11_En
#>
param(
[Parameter(Mandatory=$true, HelpMessage="Specify the URL for Windows 11 ISO")]
[string]$DownloadURL,
[Parameter(Mandatory=$false, HelpMessage="Specify path for the Windows 11 ISO to be downloaded")]
[ValidateScript({Test-Path $_ -IsValid})]
[string]$DownloadPath = "C:\windows\temp\win11.iso",
[Parameter(Mandatory=$false, HelpMessage="Specify Arguments to run with setup.exe")]
[string]$Arguments = "/auto upgrade /DynamicUpdate Disable /quiet"
)
Write-Host "Downloading ISO from $DownloadURL to $DownloadPath"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($DownloadURL, $DownloadPath)
Write-Host "Mounting ISO File"
$vol = Mount-DiskImage -ImagePath $DownloadPath -PassThru |
Get-DiskImage |
Get-Volume
$setup = '{0}:\setup.exe' -f $vol.DriveLetter
Write-Host "Starting Windows 11 Upgrade"
Start-Process cmd.exe -Wait -ArgumentList "/c $setup $Arguments"
Write-Host "Finished installing - if errors run without the /quiet command"