Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import-Module $env:SyncroModule -WarningAction SilentlyContinue
- # Scratchpad:
- # Removal
- # C:\Windows10Upgrade\Windows10UpgraderApp.exe /ForceUninstall
- # Del C:\Windows\UpdateAssistant\*.* /F /Q
- #================================================================================
- # Configuration
- #================================================================================
- # Application name (this will be used to check if application already installed)
- $name = "Windows 10"
- # Download URL (redirects will be followed)
- $dlurl = 'https://go.microsoft.com/fwlink/?LinkID=799445'
- # Installer filename (can be blank if download isn't a zip, wildcards allowed)
- $installer = "Windows10Upgrade*.exe"
- # Arguments to use for installer (can be blank)
- $arg = "/QuietInstall /SkipEULA /SkipSelfUpdate /ShowOOBE none"
- # Disk space required in MB (leave blank for no requirement)
- $diskspacerequired = '11000'
- # Temporary storage location (no trailing \)
- $homepath = "c:\windows\temp"
- #================================================================================
- # Shouldn't need to edit anything below this line
- #================================================================================
- Write-Output "$name installation starting..."
- Write-Output "Checking disk space..."
- $disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='$env:SystemDrive'" | Select-Object FreeSpace
- $disk = ([Math]::Round($Disk.Freespace / 1MB))
- if ($disk -lt $diskspacerequired) {
- write-output "$name requires $diskspacerequired MB to install but there's only $disk MB free."
- exit 1
- }
- # Test for home directory and create if it doesn't exist
- if (-not (Test-Path $homepath)) { mkdir $homepath | Out-Null }
- Set-Location $homepath
- # Prevent "You can’t install Windows on a USB flash drive using Setup" Error
- if (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control' -Name 'PortableOperatingSystem' -ErrorAction 'SilentlyContinue') {
- Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control' -Name 'PortableOperatingSystem' -Value 0
- }
- # Retrieve headers to make sure we have the final destination redirected file URL
- $dlurl = (Invoke-WebRequest -UseBasicParsing -Uri $dlurl -MaximumRedirection 0 -ErrorAction Ignore).headers.location
- Write-Output "Downloading: $dlurl"
- $dlfilename = [io.path]::GetFileName("$dlurl")
- (New-Object Net.WebClient).DownloadFile("$dlurl", "$homepath\$dlfilename")
- # Use GCI to determine filename in case wildcards are used
- $installer = (Get-ChildItem $installer).Name
- Write-Output "Installing: $homepath\$installer $arg"
- Start-Process "$installer" -ArgumentList "$arg"
- Write-Output "Cleaning up..."
- Start-Sleep -s 120
- Remove-Item $installer -Force
Advertisement
RAW Paste Data
Copied
Advertisement