mirror of
https://github.com/ntdevlabs/tiny11builder.git
synced 2024-11-24 04:45:30 +00:00
Merge pull request #141 from eugenesan/main
Add support for system ADK, Logging and Debug
This commit is contained in:
commit
dbaa1db7a9
@ -1,3 +1,7 @@
|
||||
# Enable debugging
|
||||
#Set-PSDebug -Trace 1
|
||||
|
||||
# Check if PowerShell execution is restricted
|
||||
if ((Get-ExecutionPolicy) -eq 'Restricted') {
|
||||
Write-Host "Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)"
|
||||
$response = Read-Host
|
||||
@ -8,26 +12,30 @@ if ((Get-ExecutionPolicy) -eq 'Restricted') {
|
||||
exit
|
||||
}
|
||||
}
|
||||
|
||||
# Check and run the script as admin if required
|
||||
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
|
||||
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)
|
||||
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator
|
||||
if ($myWindowsPrincipal.IsInRole($adminRole))
|
||||
{
|
||||
$Host.UI.RawUI.WindowTitle = "tiny11 builder"
|
||||
Clear-Host
|
||||
}
|
||||
else
|
||||
if (! $myWindowsPrincipal.IsInRole($adminRole))
|
||||
{
|
||||
Write-Host "Restarting Tiny11 image creator as admin in a new window, you can close this one."
|
||||
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell";
|
||||
$newProcess.Arguments = $myInvocation.MyCommand.Definition;
|
||||
$newProcess.Verb = "runas";
|
||||
[System.Diagnostics.Process]::Start($newProcess);
|
||||
exit
|
||||
}
|
||||
Write-Host "Welcome to the tiny11 image creator! Release: 04-29-2024"
|
||||
Start-Sleep -Seconds 3
|
||||
|
||||
# Start the transcript and prepare the window
|
||||
Start-Transcript -Path "$PSScriptRoot\tiny11.log" -UseMinimalHeader
|
||||
|
||||
$Host.UI.RawUI.WindowTitle = "Tiny11 image creator"
|
||||
Clear-Host
|
||||
Write-Host "Welcome to the tiny11 image creator! Release: 04-29-2024"
|
||||
|
||||
$mainOSDrive = $env:SystemDrive
|
||||
$hostArchitecture = $Env:PROCESSOR_ARCHITECTURE
|
||||
|
||||
$DriveLetter = Read-Host "Please enter the drive letter for the Windows 11 image"
|
||||
$DriveLetter = $DriveLetter + ":"
|
||||
@ -103,7 +111,6 @@ foreach ($package in $packagesToRemove) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
Write-Host "Removing Edge:"
|
||||
Remove-Item -Path "$mainOSDrive\scratchdir\Program Files (x86)\Microsoft\Edge" -Recurse -Force
|
||||
Remove-Item -Path "$mainOSDrive\scratchdir\Program Files (x86)\Microsoft\EdgeUpdate" -Recurse -Force
|
||||
@ -379,10 +386,24 @@ Write-Host "The tiny11 image is now completed. Proceeding with the making of the
|
||||
Write-Host "Copying unattended file for bypassing MS account on OOBE..."
|
||||
Copy-Item -Path "$PSScriptRoot\autounattend.xml" -Destination "$mainOSDrive\tiny11\autounattend.xml" -Force
|
||||
Write-Host "Creating ISO image..."
|
||||
& "$PSScriptRoot\oscdimg.exe" '-m' '-o' '-u2' '-udfver102' "-bootdata:2#p0,e,b$mainOSDrive\tiny11\boot\etfsboot.com#pEF,e,b$mainOSDrive\tiny11\efi\microsoft\boot\efisys.bin" "$mainOSDrive\tiny11" "$PSScriptRoot\tiny11.iso"
|
||||
$ADKDepTools = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture\Oscdimg"
|
||||
if ([System.IO.Directory]::Exists($ADKDepTools)) {
|
||||
Write-Host "Will be using oscdimg.exe from system ADK."
|
||||
$OSCDIMG = "$ADKDepTools\oscdimg.exe"
|
||||
} else {
|
||||
Write-Host "Will be using bundled oscdimg.exe."
|
||||
$OSCDIMG = "$PSScriptRoot\oscdimg.exe"
|
||||
}
|
||||
& "$OSCDIMG" '-m' '-o' '-u2' '-udfver102' "-bootdata:2#p0,e,b$mainOSDrive\tiny11\boot\etfsboot.com#pEF,e,b$mainOSDrive\tiny11\efi\microsoft\boot\efisys.bin" "$mainOSDrive\tiny11" "$PSScriptRoot\tiny11.iso"
|
||||
|
||||
# Finishing up
|
||||
Write-Host "Creation completed! Press any key to exit the script..."
|
||||
Read-Host "Press Enter to continue"
|
||||
Write-Host "Performing Cleanup..."
|
||||
Remove-Item -Path "$mainOSDrive\tiny11" -Recurse -Force
|
||||
Remove-Item -Path "$mainOSDrive\scratchdir" -Recurse -Force
|
||||
exit
|
||||
|
||||
# Stop the transcript
|
||||
Stop-Transcript
|
||||
|
||||
exit
|
||||
|
Loading…
Reference in New Issue
Block a user