Created
November 16, 2021 06:17
-
-
Save loopunit/713bd35f4c19572a13f6de54330d7195 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# This script contains all of the command shown in my blog post: Create Zero-Touch Windows 10 ISO | |
http://blogs.catapultsystems.com/mdowst/archive/2017/12/11/create-zero-touch-windows-10-iso/ | |
#> | |
$ISO = "c:\users\administrator\desktop\source.iso" | |
$FolderPath = "c:\users\administrator\desktop\iso_staging" | |
$NewISO = 'c:\users\administrator\desktop\modified.iso' | |
################################### | |
# | |
# Prep the ISO Files | |
# | |
################################### | |
# Get current drive letters | |
$drives = (Get-Volume).DriveLetter | |
# Mount the ISO image | |
$image = Mount-DiskImage -ImagePath $ISO -PassThru | |
# Get the new drive letter | |
$drive = (Get-Volume | ?{$drives -notcontains $_.DriveLetter -and $_.DriveLetter -ne $null}).DriveLetter | |
# Create destination folder if it doesn't exist | |
If (!(test-path $FolderPath)){ | |
New-Item -type directory -Path $FolderPath} | |
# Copy the ISO files | |
Get-ChildItem -Path "$($drive):\" | %{ | |
Copy-Item -Path $_.FullName -Destination $FolderPath -recurse -Force} | |
# dismount the ISO | |
$image | Dismount-DiskImage | |
# Delete the bootfix.bin | |
Remove-Item (Join-Path $FolderPath "boot\bootfix.bin") -Force | |
# Rename the efisys files | |
Rename-Item (Join-Path $FolderPath "efi\microsoft\boot\efisys.bin") "efisys_prompt.bin" | |
Rename-Item (Join-Path $FolderPath "efi\microsoft\boot\efisys_noprompt.bin") "efisys.bin" | |
# Rename install.esd to install.wim | |
If (Test-Path $(Join-Path $FolderPath "source\install.esd")){ | |
Rename-Item $(Join-Path $FolderPath "source\install.esd") "install.wim" | |
} | |
################################### | |
# | |
# Create Autounattend.xml | |
# | |
################################### | |
#[string]$password = Read-Host -Prompt "Enter the admin password to use" | |
#[string]$ComputerName = Read-Host -Prompt "Enter the computer name use '*' to randomly generate it" | |
#[string]$RegisteredOwner = Read-Host -Prompt "Enter the Registered Owner" | |
#[string]$RegisteredOrganization = Read-Host -Prompt "Enter the Registered Organization" | |
# | |
#$AutounattendXML = $(Join-Path $FolderPath "Autounattend.xml") | |
## Download the sample Autounattend.xml | |
##$Uri = "https://gist.githubusercontent.com/mdowst/e81cc0608a0c554d8c3381ebc7b6e15e/raw/dc55c6c1eef66fc0c4db0652ce8300e9ff507e0f/Autounattend.xml" | |
##Invoke-WebRequest -Uri $Uri -OutFile $AutounattendXML | |
# | |
## load the Autounattend.xml | |
#[xml]$Autounattend = Get-Content $AutounattendXML | |
# | |
## Update the values | |
#($Autounattend.unattend.settings | ?{$_.pass -eq 'oobeSystem'}).component.AutoLogon.Password.Value = $password | |
#($Autounattend.unattend.settings | ?{$_.pass -eq 'oobeSystem'}).component.UserAccounts.AdministratorPassword.Value = $password | |
#($Autounattend.unattend.settings | ?{$_.pass -eq 'specialize'}).component.ComputerName = $ComputerName | |
#($Autounattend.unattend.settings | ?{$_.pass -eq 'specialize'}).component.RegisteredOwner = $RegisteredOwner | |
#($Autounattend.unattend.settings | ?{$_.pass -eq 'specialize'}).component.RegisteredOrganization = $RegisteredOrganization | |
# | |
## Save the updated XML file | |
#$Autounattend.Save($AutounattendXML) | |
################################### | |
# | |
# Create the ISO | |
# | |
################################### | |
# Create the ISO image | |
$command = $(Join-Path 'oscdimg.exe') | |
$arguments = '-m','-o','-u2','-udfver102',"-bootdata:2#p0,e,b$(Join-Path $FolderPath 'boot\etfsboot.com')#pEF,e,b$(Join-Path $FolderPath 'efi\microsoft\boot\efisys.bin')",$FolderPath,$NewISO | |
& $command $arguments |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment