1+ # Enable debugging
2+ # Set-PSDebug -Trace 1
3+
4+ # Check if PowerShell execution is restricted
15if ((Get-ExecutionPolicy ) -eq ' Restricted' ) {
26 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)"
37 $response = Read-Host
@@ -8,26 +12,30 @@ if ((Get-ExecutionPolicy) -eq 'Restricted') {
812 exit
913 }
1014}
15+
16+ # Check and run the script as admin if required
1117$myWindowsID = [System.Security.Principal.WindowsIdentity ]::GetCurrent()
1218$myWindowsPrincipal = new-object System.Security.Principal.WindowsPrincipal($myWindowsID )
1319$adminRole = [System.Security.Principal.WindowsBuiltInRole ]::Administrator
14- if ($myWindowsPrincipal.IsInRole ($adminRole ))
15- {
16- $Host.UI.RawUI.WindowTitle = " tiny11 builder"
17- Clear-Host
18- }
19- else
20+ if (! $myWindowsPrincipal.IsInRole ($adminRole ))
2021{
22+ Write-Host " Restarting Tiny11 image creator as admin in a new window, you can close this one."
2123 $newProcess = new-object System.Diagnostics.ProcessStartInfo " PowerShell" ;
2224 $newProcess.Arguments = $myInvocation.MyCommand.Definition ;
2325 $newProcess.Verb = " runas" ;
2426 [System.Diagnostics.Process ]::Start($newProcess );
2527 exit
2628}
27- Write-Host " Welcome to the tiny11 image creator! Release: 04-29-2024"
28- Start-Sleep - Seconds 3
29+
30+ # Start the transcript and prepare the window
31+ Start-Transcript - Path " $PSScriptRoot \tiny11.log" - UseMinimalHeader
32+
33+ $Host.UI.RawUI.WindowTitle = " Tiny11 image creator"
2934Clear-Host
35+ Write-Host " Welcome to the tiny11 image creator! Release: 04-29-2024"
36+
3037$mainOSDrive = $env: SystemDrive
38+ $hostArchitecture = $Env: PROCESSOR_ARCHITECTURE
3139
3240$DriveLetter = Read-Host " Please enter the drive letter for the Windows 11 image"
3341$DriveLetter = $DriveLetter + " :"
@@ -103,7 +111,6 @@ foreach ($package in $packagesToRemove) {
103111}
104112
105113
106-
107114Write-Host " Removing Edge:"
108115Remove-Item - Path " $mainOSDrive \scratchdir\Program Files (x86)\Microsoft\Edge" - Recurse - Force
109116Remove-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
379386Write-Host " Copying unattended file for bypassing MS account on OOBE..."
380387Copy-Item - Path " $PSScriptRoot \autounattend.xml" - Destination " $mainOSDrive \tiny11\autounattend.xml" - Force
381388Write-Host " Creating ISO image..."
382- & " $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"
389+ $ADKDepTools = " C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$hostarchitecture \Oscdimg"
390+ if ([System.IO.Directory ]::Exists($ADKDepTools )) {
391+ Write-Host " Will be using oscdimg.exe from system ADK."
392+ $OSCDIMG = " $ADKDepTools \oscdimg.exe"
393+ } else {
394+ Write-Host " Will be using bundled oscdimg.exe."
395+ $OSCDIMG = " $PSScriptRoot \oscdimg.exe"
396+ }
397+ & " $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"
398+
399+ # Finishing up
383400Write-Host " Creation completed! Press any key to exit the script..."
384401Read-Host " Press Enter to continue"
385402Write-Host " Performing Cleanup..."
386403Remove-Item - Path " $mainOSDrive \tiny11" - Recurse - Force
387404Remove-Item - Path " $mainOSDrive \scratchdir" - Recurse - Force
388- exit
405+
406+ # Stop the transcript
407+ Stop-Transcript
408+
409+ exit
0 commit comments