[
  {
    "path": ".github/FUNDING.yml",
    "content": "\n\ngithub: [ntdevlabs] \npatreon: [ntdev] \nko-fi: [ntdev]\n\n# Add custom links to support your work\ncustom: ['https://paypal.me/ntdev2']\n"
  },
  {
    "path": "README.md",
    "content": "# tiny11builder\n*Scripts to build a trimmed-down Windows 11 image - now in **PowerShell**!*\n\n## Introduction :\nTiny11 builder, now completely overhauled. <br> After more than a year (for which I am so sorry) of no updates, tiny11 builder is now a much more complete and flexible solution - one script fits all. Also, it is a steppingstone for an even more fleshed-out solution.\n\nYou can now use it on ANY Windows 11 release (not just a specific build), as well as ANY language or architecture.\nThis is made possible thanks to the much-improved scripting capabilities of PowerShell, compared to the older Batch release.\n\nThis is a script created to automate the build of a streamlined Windows 11 image, similar to tiny10.\nThe script has also been updated to use DISM's recovery compression, resulting in a much smaller final ISO size, and no utilities from external sources. The only other executable included is **oscdimg.exe**, which is provided in the Windows ADK and it is used to create bootable ISO images. \nAlso included is an unattended answer file, which is used to bypass the Microsoft Account on OOBE and to deploy the image with the `/compact` flag.\nIt's open-source, **so feel free to add or remove anything you want!** Feedback is also much appreciated.\n\nAlso, for the very first time, **introducing tiny11 core builder**! A more powerful script, designed for a quick and dirty development testbed. Just the bare minimum, none of the fluff. \nThis script generates a significantly reduced Windows 11 image. However, **it's not suitable for regular use due to its lack of serviceability - you can't add languages, updates, or features post-creation**. tiny11 Core is not a full Windows 11 substitute but a rapid testing or development tool, potentially useful for VM environments.\n\n---\n\n## ⚠️ Script versions:\n- **tiny11maker.ps1** : The regular script, which removes a lot of bloat but keeps the system serviceable. You can add languages, updates, and features post-creation. This is the recommended script for regular use.\n- ⚠️ **tiny11coremaker.ps1** : The core script, which removes even more bloat but also removes the ability to service the image. You cannot add languages, updates, or features post-creation. This is recommended for quick testing or development use.\n\n## Instructions:\n1. Download Windows 11 from the [Microsoft website](https://www.microsoft.com/software-download/windows11) or [Rufus](https://github.com/pbatard/rufus)\n2. Mount the downloaded ISO image using Windows Explorer.\n3. Open **PowerShell 5.1** as Administrator. \n5. Change the script execution policy :\n```powershell\nSet-ExecutionPolicy Bypass -Scope Process\n```\n> Using `-Scope Process` you keep your original policy intact as this change only lasts for the current PowerShell session. \n\n6. Start the script :\n```powershell\nC:/path/to/your/tiny11/script.ps1 -ISO <letter> -SCRATCH <letter>\n``` \n> You can see of the script by running the `get-help` command.\n\n6. Select the drive letter where the image is mounted (only the letter, no colon (:))\n7. Select the SKU that you want the image to be based.\n8. Sit back and relax :)\n9. When the image is completed, you will see it in the folder where the script was extracted, with the name tiny11.iso\n\n---\n\n## What is removed:\n<table>\n  <tbody>\n    <tr>\n      <th>Tiny11maker</th>\n      <th>Tiny11coremaker</th>\n    </tr>\n    <tr>\n      <td>\n        <ul>\n          <li>Clipchamp</li>\n          <li>News</li>\n          <li>Weather</li>\n          <li>Xbox</li>\n          <li>GetHelp</li>\n          <li>GetStarted</li>\n          <li>Office Hub</li>\n          <li>Solitaire</li>\n          <li>PeopleApp</li>\n          <li>PowerAutomate</li>\n          <li>ToDo</li>\n          <li>Alarms</li>\n          <li>Mail and Calendar</li>\n          <li>Feedback Hub</li>\n          <li>Maps</li>\n          <li>Sound Recorder</li>\n          <li>Your Phone</li>\n          <li>Media Player</li>\n          <li>QuickAssist</li>\n          <li>Internet Explorer</li>\n          <li>Tablet PC Math</li>\n          <li>Edge</li>\n          <li>OneDrive</li>\n        </ul>\n      </td>\n      <td>\n        <ul>\n          <li>all from regular tiny +</li>\n          <li>Windows Component Store (WinSxS)</li>\n          <li>Windows Defender (only disabled, can be enabled back if needed)</li>\n          <li>Windows Update (wouldn't work without WinSxS, enabling it would put the system in a state of failure)</li>\n          <li>WinRE</li>\n        </ul>\n      </td>\n    </tr>\n  </tbody>\n</table>\n\nKeep in mind that **you cannot add back features in tiny11 core**! <br>\nYou will be asked during image creation if you want to enable .net 3.5 support!\n\n---\n\n## Known issues:\n- Although Edge is removed, there are some remnants in the Settings, but the app in itself is deleted. \n- You might have to update Winget before being able to install any apps, using Microsoft Store.\n- Outlook and Dev Home might reappear after some time. This is an ongoing battle, though the latest script update tries to prevent this more aggressively.\n- If you are using this script on arm64, you might see a glimpse of an error while running the script. This is caused by the fact that the arm64 image doesn't have OneDriveSetup.exe included in the System32 folder.\n\n---\n\n## Features to be implemented:\n- ~~disabling telemetry~~ (Implemented in the 04-29-24 release!)\n- ~~more ad suppression~~ (Partially implemented in the 09-06-25 release!)\n- improved language and arch detection\n- more flexibility in what to keep and what to delete\n- maybe a GUI???\n\nAnd that's pretty much it for now!\n## ❤️ Support the Project\n\nIf this project has helped you, please consider showing your support! A small donation helps me dedicate more time to projects like this.\nThank you!\n\n**[Patreon](http://patreon.com/ntdev) | [PayPal](http://paypal.me/ntdev2) | [Ko-fi](http://ko-fi.com/ntdev)**\nThanks for trying it and let me know how you like it!\n"
  },
  {
    "path": "autounattend.xml",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<unattend xmlns=\"urn:schemas-microsoft-com:unattend\">\r\n    <settings pass=\"oobeSystem\">\r\n        <component xmlns:wcm=\"http://schemas.microsoft.com/WMIConfig/2002/State\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"Microsoft-Windows-Shell-Setup\" processorArchitecture=\"amd64\" publicKeyToken=\"31bf3856ad364e35\" language=\"neutral\" versionScope=\"nonSxS\">\r\n            <OOBE>\r\n                <HideOnlineAccountScreens>true</HideOnlineAccountScreens>\r\n            </OOBE>\r\n        </component>\r\n    </settings>\r\n    <component xmlns:wcm=\"http://schemas.microsoft.com/WMIConfig/2002/State\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"Microsoft-Windows-Shell-Setup\" processorArchitecture=\"amd64\" publicKeyToken=\"31bf3856ad364e35\" language=\"neutral\" versionScope=\"nonSxS\">\r\n        <ConfigureChatAutoInstall>false</ConfigureChatAutoInstall>\r\n    </component>\r\n    <settings pass=\"windowsPE\">\r\n        <component xmlns:wcm=\"http://schemas.microsoft.com/WMIConfig/2002/State\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" name=\"Microsoft-Windows-Setup\" processorArchitecture=\"amd64\" publicKeyToken=\"31bf3856ad364e35\" language=\"neutral\" versionScope=\"nonSxS\">\r\n            <DynamicUpdate>\r\n                <WillShowUI>OnError</WillShowUI>\r\n            </DynamicUpdate>\r\n            <ImageInstall>\r\n                <OSImage>\r\n                    <Compact>true</Compact>\r\n                    <WillShowUI>OnError</WillShowUI>\r\n                    <InstallFrom>\r\n                        <MetaData wcm:action=\"add\">\r\n                            <Key>/IMAGE/INDEX</Key>\r\n                            <Value>1</Value>\r\n                        </MetaData>\r\n                    </InstallFrom>\r\n                </OSImage>\r\n            </ImageInstall>\r\n            <UserData>\r\n                <ProductKey>\r\n                    <Key/>\r\n                </ProductKey>\r\n            </UserData>\r\n        </component>\r\n    </settings>\r\n</unattend>\r\n"
  },
  {
    "path": "tiny11Coremaker.ps1",
    "content": "if ((Get-ExecutionPolicy) -eq 'Restricted') {\r\n    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)\"\r\n    $response = Read-Host\r\n    if ($response -eq 'yes') {\r\n        Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false\r\n    } else {\r\n        Write-Host \"The script cannot be run without changing the execution policy. Exiting...\"\r\n        exit\r\n    }\r\n}\r\n\r\n# Check and run the script as admin if required\r\n$adminSID = New-Object System.Security.Principal.SecurityIdentifier(\"S-1-5-32-544\")\r\n$adminGroup = $adminSID.Translate([System.Security.Principal.NTAccount])\r\n$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)\r\n$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator\r\nif (! $myWindowsPrincipal.IsInRole($adminRole))\r\n{\r\n    Write-Host \"Restarting Tiny11 image creator as admin in a new window, you can close this one.\"\r\n    $newProcess = new-object System.Diagnostics.ProcessStartInfo \"PowerShell\";\r\n    $newProcess.Arguments = $myInvocation.MyCommand.Definition;\r\n    $newProcess.Verb = \"runas\";\r\n    [System.Diagnostics.Process]::Start($newProcess);\r\n    exit\r\n}\r\nStart-Transcript -Path \"$PSScriptRoot\\tiny11.log\" \r\n# Ask the user for input\r\nWrite-Host \"Welcome to tiny11 core builder! BETA 09-05-25\"\r\nWrite-Host \"This script generates a significantly reduced Windows 11 image. However, it's not suitable for regular use due to its lack of serviceability - you can't add languages, updates, or features post-creation. tiny11 Core is not a full Windows 11 substitute but a rapid testing or development tool, potentially useful for VM environments.\"\r\nWrite-Host \"Do you want to continue? (y/n)\"\r\n$input = Read-Host\r\n\r\nif ($input -eq 'y') {\r\n    Write-Host \"Off we go...\"\r\nStart-Sleep -Seconds 3\r\nClear-Host\r\n\r\n$mainOSDrive = $env:SystemDrive\r\n$hostArchitecture = $Env:PROCESSOR_ARCHITECTURE\r\nNew-Item -ItemType Directory -Force -Path \"$mainOSDrive\\tiny11\\sources\" >null\r\n$DriveLetter = Read-Host \"Please enter the drive letter for the Windows 11 image\"\r\n$DriveLetter = $DriveLetter + \":\"\r\n\r\nif ((Test-Path \"$DriveLetter\\sources\\boot.wim\") -eq $false -or (Test-Path \"$DriveLetter\\sources\\install.wim\") -eq $false) {\r\n    if ((Test-Path \"$DriveLetter\\sources\\install.esd\") -eq $true) {\r\n        Write-Host \"Found install.esd, converting to install.wim...\"\r\n        &  'dism' '/English' \"/Get-WimInfo\" \"/wimfile:$DriveLetter\\sources\\install.esd\"\r\n        $index = Read-Host \"Please enter the image index\"\r\n        Write-Host ' '\r\n        Write-Host 'Converting install.esd to install.wim. This may take a while...'\r\n        & 'DISM' /Export-Image /SourceImageFile:\"$DriveLetter\\sources\\install.esd\" /SourceIndex:$index /DestinationImageFile:\"$mainOSDrive\\tiny11\\sources\\install.wim\" /Compress:max /CheckIntegrity\r\n    } else {\r\n        Write-Host \"Can't find Windows OS Installation files in the specified Drive Letter..\"\r\n        Write-Host \"Please enter the correct DVD Drive Letter..\"\r\n        exit\r\n    }\r\n}\r\n\r\nWrite-Host \"Copying Windows image...\"\r\nCopy-Item -Path \"$DriveLetter\\*\" -Destination \"$mainOSDrive\\tiny11\" -Recurse -Force > null\r\nSet-ItemProperty -Path \"$mainOSDrive\\tiny11\\sources\\install.esd\" -Name IsReadOnly -Value $false > $null 2>&1\r\nRemove-Item \"$mainOSDrive\\tiny11\\sources\\install.esd\" > $null 2>&1\r\nWrite-Host \"Copy complete!\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Host \"Getting image information:\"\r\n&  'dism' '/English' \"/Get-WimInfo\" \"/wimfile:$mainOSDrive\\tiny11\\sources\\install.wim\"\r\n$index = Read-Host \"Please enter the image index\"\r\nWrite-Host \"Mounting Windows image. This may take a while.\"\r\n$wimFilePath = \"$($env:SystemDrive)\\tiny11\\sources\\install.wim\" \r\n& takeown \"/F\" $wimFilePath \r\n& icacls $wimFilePath \"/grant\" \"$($adminGroup.Value):(F)\"\r\ntry {\r\n    Set-ItemProperty -Path $wimFilePath -Name IsReadOnly -Value $false -ErrorAction Stop\r\n} catch {\r\n    # This block will catch the error and suppress it.\r\n}\r\nNew-Item -ItemType Directory -Force -Path \"$mainOSDrive\\scratchdir\" > $null\r\n& dism /English \"/mount-image\" \"/imagefile:$($env:SystemDrive)\\tiny11\\sources\\install.wim\" \"/index:$index\" \"/mountdir:$($env:SystemDrive)\\scratchdir\"\r\n\r\n$imageIntl = & dism /English /Get-Intl \"/Image:$($env:SystemDrive)\\scratchdir\"\r\n$languageLine = $imageIntl -split '\\n' | Where-Object { $_ -match 'Default system UI language : ([a-zA-Z]{2}-[a-zA-Z]{2})' }\r\n\r\nif ($languageLine) {\r\n    $languageCode = $Matches[1]\r\n    Write-Host \"Default system UI language code: $languageCode\"\r\n} else {\r\n    Write-Host \"Default system UI language code not found.\"\r\n}\r\n\r\n$imageInfo = & 'dism' '/English' '/Get-WimInfo' \"/wimFile:$($env:SystemDrive)\\tiny11\\sources\\install.wim\" \"/index:$index\"\r\n$lines = $imageInfo -split '\\r?\\n'\r\n\r\nforeach ($line in $lines) {\r\n    if ($line -like '*Architecture : *') {\r\n        $architecture = $line -replace 'Architecture : ',''\r\n        # If the architecture is x64, replace it with amd64\r\n        if ($architecture -eq 'x64') {\r\n            $architecture = 'amd64'\r\n        }\r\n        Write-Host \"Architecture: $architecture\"\r\n        break\r\n    }\r\n}\r\n\r\nif (-not $architecture) {\r\n    Write-Host \"Architecture information not found.\"\r\n}\r\n\r\nWrite-Host \"Mounting complete! Performing removal of applications...\"\r\n\r\n$packages = & 'dism' '/English' \"/image:$($env:SystemDrive)\\scratchdir\" '/Get-ProvisionedAppxPackages' |\r\n    ForEach-Object {\r\n        if ($_ -match 'PackageName : (.*)') {\r\n            $matches[1]\r\n        }\r\n    }\r\n$packagePrefixes = 'Clipchamp.Clipchamp_', 'Microsoft.BingNews_', 'Microsoft.BingWeather_', 'Microsoft.GamingApp_', 'Microsoft.GetHelp_', 'Microsoft.Getstarted_', 'Microsoft.MicrosoftOfficeHub_', 'Microsoft.MicrosoftSolitaireCollection_', 'Microsoft.People_', 'Microsoft.PowerAutomateDesktop_', 'Microsoft.Todos_', 'Microsoft.WindowsAlarms_', 'microsoft.windowscommunicationsapps_', 'Microsoft.WindowsFeedbackHub_', 'Microsoft.WindowsMaps_', 'Microsoft.WindowsSoundRecorder_', 'Microsoft.Xbox.TCUI_', 'Microsoft.XboxGamingOverlay_', 'Microsoft.XboxGameOverlay_', 'Microsoft.XboxSpeechToTextOverlay_', 'Microsoft.YourPhone_', 'Microsoft.ZuneMusic_', 'Microsoft.ZuneVideo_', 'MicrosoftCorporationII.MicrosoftFamily_', 'MicrosoftCorporationII.QuickAssist_', 'MicrosoftTeams_', 'Microsoft.549981C3F5F10_', 'Microsoft.Windows.Copilot', 'MSTeams_', 'Microsoft.OutlookForWindows_', 'Microsoft.Windows.Teams_', 'Microsoft.Copilot_'\r\n\r\n$packagesToRemove = $packages | Where-Object {\r\n    $packageName = $_\r\n    $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like \"$_*\" })\r\n}\r\nforeach ($package in $packagesToRemove) {\r\n    write-host \"Removing $package :\"\r\n    & 'dism' '/English' \"/image:$($env:SystemDrive)\\scratchdir\" '/Remove-ProvisionedAppxPackage' \"/PackageName:$package\"\r\n}\r\n\r\nWrite-Host \"Removing of system apps complete! Now proceeding to removal of system packages...\"\r\nStart-Sleep -Seconds 1\r\nClear-Host\r\n\r\n$scratchDir = \"$($env:SystemDrive)\\scratchdir\"\r\n$packagePatterns = @(\r\n    \"Microsoft-Windows-InternetExplorer-Optional-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-Kernel-LA57-FoD-Package~31bf3856ad364e35~amd64\",\r\n    \"Microsoft-Windows-LanguageFeatures-Handwriting-$languageCode-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-LanguageFeatures-OCR-$languageCode-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-LanguageFeatures-Speech-$languageCode-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-LanguageFeatures-TextToSpeech-$languageCode-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-MediaPlayer-Package~31bf3856ad364e35\",\r\n    \"Microsoft-Windows-Wallpaper-Content-Extended-FoD-Package~31bf3856ad364e35\",\r\n    \"Windows-Defender-Client-Package~31bf3856ad364e35~\",\r\n    \"Microsoft-Windows-WordPad-FoD-Package~\",\r\n    \"Microsoft-Windows-TabletPCMath-Package~\",\r\n    \"Microsoft-Windows-StepsRecorder-Package~\"\r\n\r\n)\r\n\r\n# Get all packages\r\n$allPackages = & dism /image:$scratchDir /Get-Packages /Format:Table\r\n$allPackages = $allPackages -split \"`n\" | Select-Object -Skip 1\r\n\r\nforeach ($packagePattern in $packagePatterns) {\r\n    # Filter the packages to remove\r\n    $packagesToRemove = $allPackages | Where-Object { $_ -like \"$packagePattern*\" }\r\n\r\n    foreach ($package in $packagesToRemove) {\r\n        # Extract the package identity\r\n        $packageIdentity = ($package -split \"\\s+\")[0]\r\n\r\n        Write-Host \"Removing $packageIdentity...\"\r\n        & dism /image:$scratchDir /Remove-Package /PackageName:$packageIdentity \r\n    }\r\n}\r\n\r\nWrite-Host \"Do you want to enable .NET 3.5? This cannot be done after the image has been created! (y/n)\"\r\n$input = Read-Host\r\n\r\nif ($input -eq 'y') {\r\n    Write-Host \"Enabling .NET 3.5...\"\r\n    & 'dism'  \"/image:$scratchDir\" '/enable-feature' '/featurename:NetFX3' '/All' \"/source:$($env:SystemDrive)\\tiny11\\sources\\sxs\" \r\n    Write-Host \".NET 3.5 has been enabled.\"\r\n}\r\nelseif ($input -eq 'n') {\r\n    Write-Host \"You chose not to enable .NET 3.5. Continuing...\"\r\n}\r\nelse {\r\n    Write-Host \"Invalid input. Please enter 'y' to enable .NET 3.5 or 'n' to continue without installing .net 3.5.\"\r\n}\r\nWrite-Host \"Removing Edge:\"\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Program Files (x86)\\Microsoft\\Edge\" -Recurse -Force >null\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Program Files (x86)\\Microsoft\\EdgeUpdate\" -Recurse -Force >null\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Program Files (x86)\\Microsoft\\EdgeCore\" -Recurse -Force >null\r\nif ($architecture -eq 'amd64') {\r\n    $folderPath = Get-ChildItem -Path \"$mainOSDrive\\scratchdir\\Windows\\WinSxS\" -Filter \"amd64_microsoft-edge-webview_31bf3856ad364e35*\" -Directory | Select-Object -ExpandProperty FullName\r\n\r\n    if ($folderPath) {\r\n        & 'takeown' '/f' $folderPath '/r' >null\r\n        & icacls $folderPath  \"/grant\" \"$($adminGroup.Value):(F)\" '/T' '/C' >null\r\n        Remove-Item -Path $folderPath -Recurse -Force >null\r\n    } else {\r\n        Write-Host \"Folder not found.\"\r\n    }\r\n} elseif ($architecture -eq 'arm64') {\r\n    $folderPath = Get-ChildItem -Path \"$mainOSDrive\\scratchdir\\Windows\\WinSxS\" -Filter \"arm64_microsoft-edge-webview_31bf3856ad364e35*\" -Directory | Select-Object -ExpandProperty FullName >null\r\n\r\n    if ($folderPath) {\r\n        & 'takeown' '/f' $folderPath '/r'>null\r\n        & icacls $folderPath  \"/grant\" \"$($adminGroup.Value):(F)\" '/T' '/C' >null\r\n        Remove-Item -Path $folderPath -Recurse -Force >null\r\n    } else {\r\n        Write-Host \"Folder not found.\"\r\n    }\r\n} else {\r\n    Write-Host \"Unknown architecture: $architecture\"\r\n}\r\n& 'takeown' '/f' \"$mainOSDrive\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" '/r'\r\n& 'icacls' \"$mainOSDrive\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" '/grant' \"$($adminGroup.Value):(F)\" '/T' '/C'\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" -Recurse -Force\r\nWrite-Host \"Removing WinRE\"\r\n& 'takeown' '/f' \"$mainOSDrive\\scratchdir\\Windows\\System32\\Recovery\" '/r'\r\n& 'icacls' \"$mainOSDrive\\scratchdir\\Windows\\System32\\Recovery\" '/grant' 'Administrators:F' '/T' '/C'\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Windows\\System32\\Recovery\\winre.wim\" -Recurse -Force\r\nNew-Item -Path \"$mainOSDrive\\scratchdir\\Windows\\System32\\Recovery\\winre.wim\" -ItemType File -Force\r\nWrite-Host \"Removing OneDrive:\"\r\n& 'takeown' '/f' \"$mainOSDrive\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" >null\r\n& 'icacls' \"$mainOSDrive\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" '/grant' \"$($adminGroup.Value):(F)\" '/T' '/C' >null\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" -Force >null\r\nWrite-Host \"Removal complete!\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Host \"Taking ownership of the WinSxS folder. This might take a while...\"\r\n& 'takeown' '/f' \"$mainOSDrive\\scratchdir\\Windows\\WinSxS\" '/r'\r\n& 'icacls' \"$mainOSDrive\\scratchdir\\Windows\\WinSxS\" '/grant' \"$($adminGroup.Value):(F)\" '/T' '/C'\r\nWrite-host \"Complete!\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Host \"Preparing...\"\r\n$folderPath = Join-Path -Path $mainOSDrive -ChildPath \"\\scratchdir\\Windows\\WinSxS_edit\"\r\n$sourceDirectory = \"$mainOSDrive\\scratchdir\\Windows\\WinSxS\"\r\n$destinationDirectory = \"$mainOSDrive\\scratchdir\\Windows\\WinSxS_edit\"\r\nNew-Item -Path $folderPath -ItemType Directory\r\nif ($architecture -eq \"amd64\") {\r\n   $dirsToCopy = @(\r\n        \"x86_microsoft.windows.common-controls_6595b64144ccf1df_*\",\r\n        \"x86_microsoft.windows.gdiplus_6595b64144ccf1df_*\",    \r\n        \"x86_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*\",\r\n        \"x86_microsoft.windows.isolationautomation_6595b64144ccf1df_*\",\r\n        \"x86_microsoft-windows-s..ngstack-onecorebase_31bf3856ad364e35_*\",\r\n        \"x86_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_*\",\r\n        \"x86_microsoft-windows-servicingstack_31bf3856ad364e35_*\",\r\n        \"x86_microsoft-windows-servicingstack-inetsrv_*\",\r\n        \"x86_microsoft-windows-servicingstack-onecore_*\",\r\n        \"amd64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*\",\r\n        \"amd64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*\",\r\n        \"amd64_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\",\r\n        \"amd64_microsoft.windows.common-controls_6595b64144ccf1df_*\",\r\n        \"amd64_microsoft.windows.gdiplus_6595b64144ccf1df_*\",\r\n        \"amd64_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*\",\r\n        \"amd64_microsoft.windows.isolationautomation_6595b64144ccf1df_*\",\r\n        \"amd64_microsoft-windows-s..stack-inetsrv-extra_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-s..stack-msg.resources_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-servicingstack_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-servicingstack-inetsrv_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-servicingstack-msg_31bf3856ad364e35_*\",\r\n        \"amd64_microsoft-windows-servicingstack-onecore_31bf3856ad364e35_*\",\r\n        \"Catalogs\",\r\n        \"FileMaps\",\r\n        \"Fusion\",\r\n        \"InstallTemp\",\r\n        \"Manifests\",\r\n        \"x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*\",\r\n        \"x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*\",\r\n        \"x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\",\r\n        \"x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\"\r\n    )\r\n # Copy each directory\r\n   foreach ($dir in $dirsToCopy) {\r\n        $sourceDirs = Get-ChildItem -Path $sourceDirectory -Filter $dir -Directory\r\n        foreach ($sourceDir in $sourceDirs) {\r\n            $destDir = Join-Path -Path $destinationDirectory -ChildPath $sourceDir.Name\r\n            Write-Host \"Copying $sourceDir.FullName to $destDir\"\r\n            Copy-Item -Path $sourceDir.FullName -Destination $destDir -Recurse -Force\r\n        }\r\n    }\r\n}\r\n elseif ($architecture -eq \"arm64\") {\r\n    # Specify the list of files to copy\r\n     $dirsToCopy = @(\r\n        \"arm64_microsoft-windows-servicingstack-onecore_31bf3856ad364e35_*\",\r\n        \"Catalogs\"\r\n        \"FileMaps\"\r\n        \"Fusion\"\r\n        \"InstallTemp\"\r\n        \"Manifests\"\r\n        \"SettingsManifests\"\r\n        \"Temp\"\r\n        \"x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*\"\r\n        \"x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*\"\r\n        \"x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\"\r\n        \"x86_microsoft.windows.common-controls_6595b64144ccf1df_*\"\r\n        \"x86_microsoft.windows.gdiplus_6595b64144ccf1df_*\"\r\n        \"x86_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*\"\r\n        \"x86_microsoft.windows.isolationautomation_6595b64144ccf1df_*\"\r\n        \"arm_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\"\r\n        \"arm_microsoft.windows.common-controls_6595b64144ccf1df_*\"\r\n        \"arm_microsoft.windows.gdiplus_6595b64144ccf1df_*\"\r\n        \"arm_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*\"\r\n        \"arm_microsoft.windows.isolationautomation_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*\"\r\n        \"arm64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*\"\r\n        \"arm64_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft.windows.common-controls_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft.windows.gdiplus_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft.windows.isolationautomation_6595b64144ccf1df_*\"\r\n        \"arm64_microsoft-windows-servicing-adm_31bf3856ad364e35_*\"\r\n        \"arm64_microsoft-windows-servicingcommon_31bf3856ad364e35_*\"\r\n        \"arm64_microsoft-windows-servicing-onecore-uapi_31bf3856ad364e35_*\"\r\n        \"arm64_microsoft-windows-servicingstack_31bf3856ad364e35_*\"\r\n        \"arm64_microsoft-windows-servicingstack-inetsrv_31bf3856ad364e35_*\"\r\n        \"arm64_microsoft-windows-servicingstack-msg_31bf3856ad364e35_*\"\r\n    )\r\n}\r\nforeach ($dir in $dirsToCopy) {\r\n        $sourceDirs = Get-ChildItem -Path $sourceDirectory -Filter $dir -Directory\r\n        foreach ($sourceDir in $sourceDirs) {\r\n            $destDir = Join-Path -Path $destinationDirectory -ChildPath $sourceDir.Name\r\n            Write-Host \"Copying $sourceDir.FullName to $destDir\"\r\n            Copy-Item -Path $sourceDir.FullName -Destination $destDir -Recurse -Force\r\n        }\r\n    }  \r\n\r\n\r\nWrite-Host \"Deleting WinSxS. This may take a while...\"\r\n        Remove-Item -Path $mainOSDrive\\scratchdir\\Windows\\WinSxS -Recurse -Force\r\n\r\nRename-Item -Path $mainOSDrive\\scratchdir\\Windows\\WinSxS_edit -NewName $mainOSDrive\\scratchdir\\Windows\\WinSxS\r\nWrite-Host \"Complete!\"\r\n\r\nWrite-Host \"Loading registry...\"\r\nreg load HKLM\\zCOMPONENTS $ScratchDisk\\scratchdir\\Windows\\System32\\config\\COMPONENTS | Out-Null\r\nreg load HKLM\\zDEFAULT $ScratchDisk\\scratchdir\\Windows\\System32\\config\\default | Out-Null\r\nreg load HKLM\\zNTUSER $ScratchDisk\\scratchdir\\Users\\Default\\ntuser.dat | Out-Null\r\nreg load HKLM\\zSOFTWARE $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SOFTWARE | Out-Null\r\nreg load HKLM\\zSYSTEM $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SYSTEM | Out-Null\r\nWrite-Host \"Bypassing system requirements(on the system image):\"\r\n& 'reg' 'add' 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV1' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV2' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV1' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV2' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassCPUCheck' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassRAMCheck' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassSecureBootCheck' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassStorageCheck' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassTPMCheck' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\MoSetup' '/v' 'AllowUpgradesWithUnsupportedTPMOrCPU' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Disabling Sponsored Apps:\"\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'OemPreInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'PreInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SilentInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' '/v' 'DisableWindowsConsumerFeatures' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'ContentDeliveryAllowed' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\PolicyManager\\current\\device\\Start' '/v' 'ConfigureStartPins' '/t' 'REG_SZ' '/d' '{\"pinnedList\": [{}]}' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'ContentDeliveryAllowed' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'ContentDeliveryAllowed' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'FeatureManagementEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'OemPreInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'PreInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'PreInstalledAppsEverEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SilentInstalledAppsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SoftLandingEnabled' '/t' 'REG_DWORD' '/d' '0' '/f'| Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContentEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-310093Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-338388Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-338389Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-338393Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-353694Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContent-353696Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SubscribedContentEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' '/v' 'SystemPaneSuggestionsEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\PushToInstall' '/v' 'DisablePushToInstall' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\MRT' '/v' 'DontOfferThroughWUAU' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'delete' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\\Subscriptions' '/f' | Out-Null\r\n& 'reg' 'delete' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\\SuggestedApps' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' '/v' 'DisableConsumerAccountStateContent' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' '/v' 'DisableCloudOptimizedContent' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Enabling Local Accounts on OOBE:\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OOBE' '/v' 'BypassNRO' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nCopy-Item -Path \"$PSScriptRoot\\autounattend.xml\" -Destination \"$ScratchDisk\\scratchdir\\Windows\\System32\\Sysprep\\autounattend.xml\" -Force | Out-Null\r\nWrite-Host \"Disabling Reserved Storage:\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ReserveManager' '/v' 'ShippedWithReserves' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\nWrite-Host \"Disabling BitLocker Device Encryption\"\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\ControlSet001\\Control\\BitLocker' '/v' 'PreventDeviceEncryption' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Disabling Chat icon:\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Windows Chat' '/v' 'ChatIcon' '/t' 'REG_DWORD' '/d' '3' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced' '/v' 'TaskbarMn' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\nWrite-Host \"Removing Edge related registries\"\r\nreg delete \"HKEY_LOCAL_MACHINE\\zSOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge\" /f | Out-Null\r\nreg delete \"HKEY_LOCAL_MACHINE\\zSOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge Update\" /f | Out-Null\r\nWrite-Host \"Disabling OneDrive folder backup\"\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\OneDrive\" '/v' 'DisableFileSyncNGSC' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Disabling Telemetry:\"\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\AdvertisingInfo' '/v' 'Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\Privacy' '/v' 'TailoredExperiencesWithDiagnosticDataEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Speech_OneCore\\Settings\\OnlineSpeechPrivacy' '/v' 'HasAccepted' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Input\\TIPC' '/v' 'Enabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization' '/v' 'RestrictImplicitInkCollection' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization' '/v' 'RestrictImplicitTextCollection' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization\\TrainedDataStore' '/v' 'HarvestContacts' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Software\\Microsoft\\Personalization\\Settings' '/v' 'AcceptedPrivacyPolicy' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\DataCollection' '/v' 'AllowTelemetry' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\ControlSet001\\Services\\dmwappushservice' '/v' 'Start' '/t' 'REG_DWORD' '/d' '4' '/f' | Out-Null\r\nWrite-Host \"Prevents installation or DevHome and Outlook:\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Orchestrator\\UScheduler\\OutlookUpdate' '/v' 'workCompleted' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Orchestrator\\UScheduler\\DevHomeUpdate' '/v' 'workCompleted' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'delete' 'HKLM\\zSOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\OutlookUpdate' '/f' | Out-Null\r\n& 'reg' 'delete' 'HKLM\\zSOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\DevHomeUpdate' '/f' | Out-Null\r\nWrite-Host \"Disabling Copilot\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsCopilot' '/v' 'TurnOffWindowsCopilot' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Edge' '/v' 'HubsSidebarEnabled' '/t' 'REG_DWORD' '/d' '0' '/f' | Out-Null\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Explorer' '/v' 'DisableSearchBoxSuggestions' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Prevents installation of Teams:\"\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Teams' '/v' 'DisableInstallation' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\nWrite-Host \"Prevent installation of New Outlook\":\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Windows Mail' '/v' 'PreventRun' '/t' 'REG_DWORD' '/d' '1' '/f' | Out-Null\r\n$tasksPath = \"C:\\scratchdir\\Windows\\System32\\Tasks\"\r\n\r\nWrite-Host \"Deleting scheduled task definition files...\"\r\n\r\n# Application Compatibility Appraiser\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Application Experience\\Microsoft Compatibility Appraiser\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Customer Experience Improvement Program (removes the entire folder and all tasks within it)\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Customer Experience Improvement Program\" -Recurse -Force -ErrorAction SilentlyContinue\r\n\r\n# Program Data Updater\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Chkdsk Proxy\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Chkdsk\\Proxy\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Windows Error Reporting (QueueReporting)\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Windows Error Reporting\\QueueReporting\" -Force -ErrorAction SilentlyContinue\r\n\r\nWrite-Host \"Task files have been deleted.\"\r\nWrite-Host \"Disabling Windows Update...\"\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\" '/v' 'StopWUPostOOBE1' '/t' 'REG_SZ' '/d' 'net stop wuauserv' '/f'\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\" '/v' 'StopWUPostOOBE2' '/t' 'REG_SZ' '/d' 'sc stop wuauserv' '/f'\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\" '/v' 'StopWUPostOOBE3' '/t' 'REG_SZ' '/d' 'sc config wuauserv start= disabled' '/f'\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\" '/v' 'DisbaleWUPostOOBE1' '/t' 'REG_SZ' '/d' 'reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\wuauserv /v Start /t REG_DWORD /d 4 /f' '/f'\r\n& 'reg' 'add' \"HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\" '/v' 'DisbaleWUPostOOBE2' '/t' 'REG_SZ' '/d' 'reg add HKLM\\SYSTEM\\ControlSet001\\Services\\wuauserv /v Start /t REG_DWORD /d 4 /f' '/f'\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate' '/v' 'DoNotConnectToWindowsUpdateInternetLocations' '/t' 'REG_DWORD' '/d' '1' '/f'\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate' '/v' 'DisableWindowsUpdateAccess' '/t' 'REG_DWORD' '/d' '1' '/f' \r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate' '/v' 'WUServer' '/t' 'REG_SZ' '/d' 'localhost' '/f' \r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate' '/v' 'WUStatusServer' '/t' 'REG_SZ' '/d' 'localhost' '/f' \r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate' '/v' 'UpdateServiceUrlAlternate' '/t' 'REG_SZ' '/d' 'localhost' '/f' \r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU' '/v' 'UseWUServer' '/t' 'REG_DWORD' '/d' '1' '/f' \r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OOBE' '/v' 'DisableOnline' '/t' 'REG_DWORD' '/d' '1' '/f' \r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\ControlSet001\\Services\\wuauserv' '/v' 'Start' '/t' 'REG_DWORD' '/d' '4' '/f' \r\n& 'reg' 'delete' 'HKLM\\zSYSTEM\\ControlSet001\\Services\\WaaSMedicSVC' '/f'\r\n& 'reg' 'delete' 'HKLM\\zSYSTEM\\ControlSet001\\Services\\UsoSvc' '/f'\r\n& 'reg' 'add' 'HKEY_LOCAL_MACHINE\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsUpdate\\AU' '/v' 'NoAutoUpdate' '/t' 'REG_DWORD' '/d' '1' '/f'\r\nWrite-Host \"Disabling Windows Defender\"\r\n# Set registry values for Windows Defender services\r\n$servicePaths = @(\r\n    \"WinDefend\",\r\n    \"WdNisSvc\",\r\n    \"WdNisDrv\",\r\n    \"WdFilter\",\r\n    \"Sense\"\r\n)\r\n\r\nforeach ($path in $servicePaths) {\r\n    Set-ItemProperty -Path \"HKLM:\\zSYSTEM\\ControlSet001\\Services\\$path\" -Name \"Start\" -Value 4\r\n}\r\n& 'reg' 'add' 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer' '/v' 'SettingsPageVisibility' '/t' 'REG_SZ' '/d' 'hide:virus;windowsupdate' '/f' \r\nWrite-Host \"Tweaking complete!\"\r\nWrite-Host \"Unmounting Registry...\"\r\nreg unload HKLM\\zCOMPONENTS >null\r\nreg unload HKLM\\zDEFAULT >null\r\nreg unload HKLM\\zNTUSER >null\r\nreg unload HKLM\\zSOFTWARE\r\nreg unload HKLM\\zSYSTEM >null\r\nWrite-Host \"Cleaning up image...\"\r\n& 'dism' '/English' \"/image:$mainOSDrive\\scratchdir\" '/Cleanup-Image' '/StartComponentCleanup' '/ResetBase' >null\r\nWrite-Host \"Cleanup complete.\"\r\nWrite-Host ' '\r\nWrite-Host \"Unmounting image...\"\r\n& 'dism' '/English' '/unmount-image' \"/mountdir:$mainOSDrive\\scratchdir\" '/commit'\r\nWrite-Host \"Exporting image...\"\r\n& 'dism' '/English' '/Export-Image' \"/SourceImageFile:$mainOSDrive\\tiny11\\sources\\install.wim\" \"/SourceIndex:$index\" \"/DestinationImageFile:$mainOSDrive\\tiny11\\sources\\install2.wim\" '/compress:max'\r\nRemove-Item -Path \"$mainOSDrive\\tiny11\\sources\\install.wim\" -Force >null\r\nRename-Item -Path \"$mainOSDrive\\tiny11\\sources\\install2.wim\" -NewName \"install.wim\" >null\r\nWrite-Host \"Windows image completed. Continuing with boot.wim.\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Host \"Mounting boot image:\"\r\n$wimFilePath = \"$($env:SystemDrive)\\tiny11\\sources\\boot.wim\" \r\n& takeown \"/F\" $wimFilePath >null\r\n& icacls $wimFilePath \"/grant\" \"$($adminGroup.Value):(F)\"\r\nSet-ItemProperty -Path $wimFilePath -Name IsReadOnly -Value $false\r\n& 'dism' '/English' '/mount-image' \"/imagefile:$mainOSDrive\\tiny11\\sources\\boot.wim\" '/index:2' \"/mountdir:$mainOSDrive\\scratchdir\"\r\nWrite-Host \"Loading registry...\"\r\nreg load HKLM\\zCOMPONENTS $mainOSDrive\\scratchdir\\Windows\\System32\\config\\COMPONENTS\r\nreg load HKLM\\zDEFAULT $mainOSDrive\\scratchdir\\Windows\\System32\\config\\default\r\nreg load HKLM\\zNTUSER $mainOSDrive\\scratchdir\\Users\\Default\\ntuser.dat\r\nreg load HKLM\\zSOFTWARE $mainOSDrive\\scratchdir\\Windows\\System32\\config\\SOFTWARE\r\nreg load HKLM\\zSYSTEM $mainOSDrive\\scratchdir\\Windows\\System32\\config\\SYSTEM\r\nWrite-Host \"Bypassing system requirements(on the setup image):\"\r\n& 'reg' 'add' 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV1' '/t' 'REG_DWORD' '/d' '0' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV2' '/t' 'REG_DWORD' '/d' '0' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV1' '/t' 'REG_DWORD' '/d' '0' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' '/v' 'SV2' '/t' 'REG_DWORD' '/d' '0' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassCPUCheck' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassRAMCheck' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassSecureBootCheck' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassStorageCheck' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\LabConfig' '/v' 'BypassTPMCheck' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKLM\\zSYSTEM\\Setup\\MoSetup' '/v' 'AllowUpgradesWithUnsupportedTPMOrCPU' '/t' 'REG_DWORD' '/d' '1' '/f' >null\r\n& 'reg' 'add' 'HKEY_LOCAL_MACHINE\\zSYSTEM\\Setup' '/v' 'CmdLine' '/t' 'REG_SZ' '/d' 'X:\\sources\\setup.exe' '/f' >null\r\nWrite-Host \"Tweaking complete!\"\r\nWrite-Host \"Unmounting Registry...\"\r\nreg unload HKLM\\zCOMPONENTS >null\r\nreg unload HKLM\\zDEFAULT >null\r\nreg unload HKLM\\zNTUSER >null\r\nreg unload HKLM\\zSOFTWARE >null\r\nreg unload HKLM\\zSYSTEM >null\r\nWrite-Host \"Unmounting image...\"\r\n& 'dism' '/English' '/unmount-image' \"/mountdir:$mainOSDrive\\scratchdir\" '/commit'\r\nClear-Host\r\nWrite-Host \"Exporting ESD. This may take a while...\"\r\n& dism /Export-Image /SourceImageFile:\"$mainOSDrive\\tiny11\\sources\\install.wim\" /SourceIndex:1 /DestinationImageFile:\"$mainOSDrive\\tiny11\\sources\\install.esd\" /Compress:recovery\r\nRemove-Item \"$mainOSDrive\\tiny11\\sources\\install.wim\" > $null 2>&1\r\nWrite-Host \"The tiny11 image is now completed. Proceeding with the making of the ISO...\"\r\nWrite-Host \"Creating ISO image...\"\r\n$ADKDepTools = \"C:\\Program Files (x86)\\Windows Kits\\10\\Assessment and Deployment Kit\\Deployment Tools\\$hostarchitecture\\Oscdimg\"\r\n$localOSCDIMGPath = \"$PSScriptRoot\\oscdimg.exe\"\r\n\r\nif ([System.IO.Directory]::Exists($ADKDepTools)) {\r\n    Write-Host \"Will be using oscdimg.exe from system ADK.\"\r\n    $OSCDIMG = \"$ADKDepTools\\oscdimg.exe\"\r\n} else {\r\n    Write-Host \"ADK folder not found. Will be using bundled oscdimg.exe.\"\r\n    \r\n    \r\n    $url = \"https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe\"\r\n\r\n    if (-not (Test-Path -Path $localOSCDIMGPath)) {\r\n        Write-Host \"Downloading oscdimg.exe...\"\r\n        Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath\r\n\r\n        if (Test-Path $localOSCDIMGPath) {\r\n            Write-Host \"oscdimg.exe downloaded successfully.\"\r\n        } else {\r\n            Write-Error \"Failed to download oscdimg.exe.\"\r\n            exit 1\r\n        }\r\n    } else {\r\n        Write-Host \"oscdimg.exe already exists locally.\"\r\n    }\r\n\r\n    $OSCDIMG = $localOSCDIMGPath\r\n}\r\n\r\n& \"$OSCDIMG\" '-m' '-o' '-u2' '-udfver102' \"-bootdata:2#p0,e,b$ScratchDisk\\tiny11\\boot\\etfsboot.com#pEF,e,b$ScratchDisk\\tiny11\\efi\\microsoft\\boot\\efisys.bin\" \"$ScratchDisk\\tiny11\" \"$PSScriptRoot\\tiny11.iso\"\r\n\r\n# Finishing up\r\nWrite-Host \"Creation completed! Press any key to exit the script...\"\r\nRead-Host \"Press Enter to continue\"\r\nWrite-Host \"Performing Cleanup...\"\r\nRemove-Item -Path \"$mainOSDrive\\tiny11\" -Recurse -Force >null\r\nRemove-Item -Path \"$mainOSDrive\\scratchdir\" -Recurse -Force >null\r\n\r\n# Stop the transcript\r\nStop-Transcript\r\n\r\nexit\r\n}\r\nelseif ($input -eq 'n') {\r\n    Write-Host \"You chose not to continue. The script will now exit.\"\r\n    exit\r\n}\r\nelse {\r\n    Write-Host \"Invalid input. Please enter 'y' to continue or 'n' to exit.\"\r\n}\r\n"
  },
  {
    "path": "tiny11maker.ps1",
    "content": "<#\r\n.SYNOPSIS\r\n    Scripts to build a trimmed-down Windows 11 image.\r\n\r\n.DESCRIPTION\r\n    This is a script created to automate the build of a streamlined Windows 11 image, similar to tiny10.\r\n    My main goal is to use only Microsoft utilities like DISM, and no utilities from external sources.\r\n    The only executable included is oscdimg.exe, which is provided in the Windows ADK and it is used to create bootable ISO images.\r\n\r\n.PARAMETER ISO\r\n    Drive letter given to the mounted iso (eg: E)\r\n\r\n.PARAMETER SCRATCH\r\n    Drive letter of the desired scratch disk (eg: D)\r\n\r\n.EXAMPLE\r\n    .\\tiny11maker.ps1 E D\r\n    .\\tiny11maker.ps1 -ISO E -SCRATCH D\r\n    .\\tiny11maker.ps1 -SCRATCH D -ISO E\r\n    .\\tiny11maker.ps1\r\n\r\n    *If you ordinal parameters the first one must be the mounted iso. The second is the scratch drive.\r\n    prefer the use of full named parameter (eg: \"-ISO\") as you can put in the order you want.\r\n\r\n.NOTES\r\n    Auteur: ntdevlabs\r\n    Date: 09-07-25\r\n#>\r\n\r\n#---------[ Parameters ]---------#\r\nparam (\r\n    [ValidatePattern('^[c-zC-Z]$')][string]$ISO,\r\n    [ValidatePattern('^[c-zC-Z]$')][string]$SCRATCH\r\n)\r\n\r\nif (-not $SCRATCH) {\r\n    $ScratchDisk = $PSScriptRoot -replace '[\\\\]+$', ''\r\n} else {\r\n    $ScratchDisk = $SCRATCH + \":\"\r\n}\r\n\r\n#---------[ Functions ]---------#\r\nfunction Set-RegistryValue {\r\n    param (\r\n        [string]$path,\r\n        [string]$name,\r\n        [string]$type,\r\n        [string]$value\r\n    )\r\n    try {\r\n        & 'reg' 'add' $path '/v' $name '/t' $type '/d' $value '/f' | Out-Null\r\n        Write-Output \"Set registry value: $path\\$name\"\r\n    } catch {\r\n        Write-Output \"Error setting registry value: $_\"\r\n    }\r\n}\r\n\r\nfunction Remove-RegistryValue {\r\n    param (\r\n\t\t[string]$path\r\n\t)\r\n\ttry {\r\n\t\t& 'reg' 'delete' $path '/f' | Out-Null\r\n\t\tWrite-Output \"Removed registry value: $path\"\r\n\t} catch {\r\n\t\tWrite-Output \"Error removing registry value: $_\"\r\n\t}\r\n}\r\n\r\n#---------[ Execution ]---------#\r\n# Check if PowerShell execution is restricted\r\nif ((Get-ExecutionPolicy) -eq 'Restricted') {\r\n    Write-Output \"Your current PowerShell Execution Policy is set to Restricted, which prevents scripts from running. Do you want to change it to RemoteSigned? (yes/no)\"\r\n    $response = Read-Host\r\n    if ($response -eq 'yes') {\r\n        Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Confirm:$false\r\n    } else {\r\n        Write-Output \"The script cannot be run without changing the execution policy. Exiting...\"\r\n        exit\r\n    }\r\n}\r\n\r\n# Check and run the script as admin if required\r\n$adminSID = New-Object System.Security.Principal.SecurityIdentifier(\"S-1-5-32-544\")\r\n$adminGroup = $adminSID.Translate([System.Security.Principal.NTAccount])\r\n$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID)\r\n$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator\r\nif (! $myWindowsPrincipal.IsInRole($adminRole))\r\n{\r\n    Write-Output \"Restarting Tiny11 image creator as admin in a new window, you can close this one.\"\r\n    $newProcess = new-object System.Diagnostics.ProcessStartInfo \"PowerShell\";\r\n    $newProcess.Arguments = $myInvocation.MyCommand.Definition;\r\n    $newProcess.Verb = \"runas\";\r\n    [System.Diagnostics.Process]::Start($newProcess);\r\n    exit\r\n}\r\n\r\nif (-not (Test-Path -Path \"$PSScriptRoot/autounattend.xml\")) {\r\n    Invoke-RestMethod \"https://raw.githubusercontent.com/ntdevlabs/tiny11builder/refs/heads/main/autounattend.xml\" -OutFile \"$PSScriptRoot/autounattend.xml\"\r\n}\r\n\r\n# Start the transcript and prepare the window\r\nStart-Transcript -Path \"$PSScriptRoot\\tiny11_$(get-date -f yyyyMMdd_HHmms).log\"\r\n\r\n$Host.UI.RawUI.WindowTitle = \"Tiny11 image creator\"\r\nClear-Host\r\nWrite-Output \"Welcome to the tiny11 image creator! Release: 09-07-25\"\r\n\r\n$hostArchitecture = $Env:PROCESSOR_ARCHITECTURE\r\nNew-Item -ItemType Directory -Force -Path \"$ScratchDisk\\tiny11\\sources\" | Out-Null\r\ndo {\r\n    if (-not $ISO) {\r\n        $DriveLetter = Read-Host \"Please enter the drive letter for the Windows 11 image\"\r\n    } else {\r\n        $DriveLetter = $ISO\r\n    }\r\n    if ($DriveLetter -match '^[c-zC-Z]$') {\r\n        $DriveLetter = $DriveLetter + \":\"\r\n        Write-Output \"Drive letter set to $DriveLetter\"\r\n    } else {\r\n        Write-Output \"Invalid drive letter. Please enter a letter between C and Z.\"\r\n    }\r\n} while ($DriveLetter -notmatch '^[c-zC-Z]:$')\r\n\r\nif ((Test-Path \"$DriveLetter\\sources\\boot.wim\") -eq $false -or (Test-Path \"$DriveLetter\\sources\\install.wim\") -eq $false) {\r\n    if ((Test-Path \"$DriveLetter\\sources\\install.esd\") -eq $true) {\r\n        Write-Output \"Found install.esd, converting to install.wim...\"\r\n        Get-WindowsImage -ImagePath $DriveLetter\\sources\\install.esd\r\n        $index = Read-Host \"Please enter the image index\"\r\n        Write-Output ' '\r\n        Write-Output 'Converting install.esd to install.wim. This may take a while...'\r\n        Export-WindowsImage -SourceImagePath $DriveLetter\\sources\\install.esd -SourceIndex $index -DestinationImagePath $ScratchDisk\\tiny11\\sources\\install.wim -Compressiontype Maximum -CheckIntegrity\r\n    } else {\r\n        Write-Output \"Can't find Windows OS Installation files in the specified Drive Letter..\"\r\n        Write-Output \"Please enter the correct DVD Drive Letter..\"\r\n        exit\r\n    }\r\n}\r\n\r\nWrite-Output \"Copying Windows image...\"\r\nCopy-Item -Path \"$DriveLetter\\*\" -Destination \"$ScratchDisk\\tiny11\" -Recurse -Force | Out-Null\r\nSet-ItemProperty -Path \"$ScratchDisk\\tiny11\\sources\\install.esd\" -Name IsReadOnly -Value $false > $null 2>&1\r\nRemove-Item \"$ScratchDisk\\tiny11\\sources\\install.esd\" > $null 2>&1\r\nWrite-Output \"Copy complete!\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Output \"Getting image information:\"\r\n$ImagesIndex = (Get-WindowsImage -ImagePath $ScratchDisk\\tiny11\\sources\\install.wim).ImageIndex\r\nwhile ($ImagesIndex -notcontains $index) {\r\n    Get-WindowsImage -ImagePath $ScratchDisk\\tiny11\\sources\\install.wim\r\n    $index = Read-Host \"Please enter the image index\"\r\n}\r\nWrite-Output \"Mounting Windows image. This may take a while.\"\r\n$wimFilePath = \"$ScratchDisk\\tiny11\\sources\\install.wim\"\r\n& takeown \"/F\" $wimFilePath\r\n& icacls $wimFilePath \"/grant\" \"$($adminGroup.Value):(F)\"\r\ntry {\r\n    Set-ItemProperty -Path $wimFilePath -Name IsReadOnly -Value $false -ErrorAction Stop\r\n} catch {\r\n    # This block will catch the error and suppress it.\r\n\tWrite-Error \"$wimFilePath not found\"\r\n}\r\nNew-Item -ItemType Directory -Force -Path \"$ScratchDisk\\scratchdir\" > $null\r\nMount-WindowsImage -ImagePath $ScratchDisk\\tiny11\\sources\\install.wim -Index $index -Path $ScratchDisk\\scratchdir\r\n\r\n$imageIntl = & dism /English /Get-Intl \"/Image:$($ScratchDisk)\\scratchdir\"\r\n$languageLine = $imageIntl -split '\\n' | Where-Object { $_ -match 'Default system UI language : ([a-zA-Z]{2}-[a-zA-Z]{2})' }\r\n\r\nif ($languageLine) {\r\n    $languageCode = $Matches[1]\r\n    Write-Output \"Default system UI language code: $languageCode\"\r\n} else {\r\n    Write-Output \"Default system UI language code not found.\"\r\n}\r\n\r\n$imageInfo = & 'dism' '/English' '/Get-WimInfo' \"/wimFile:$($ScratchDisk)\\tiny11\\sources\\install.wim\" \"/index:$index\"\r\n$lines = $imageInfo -split '\\r?\\n'\r\n\r\nforeach ($line in $lines) {\r\n    if ($line -like '*Architecture : *') {\r\n        $architecture = $line -replace 'Architecture : ',''\r\n        # If the architecture is x64, replace it with amd64\r\n        if ($architecture -eq 'x64') {\r\n            $architecture = 'amd64'\r\n        }\r\n        Write-Output \"Architecture: $architecture\"\r\n        break\r\n    }\r\n}\r\n\r\nif (-not $architecture) {\r\n    Write-Output \"Architecture information not found.\"\r\n}\r\n\r\nWrite-Output \"Mounting complete! Performing removal of applications...\"\r\n\r\n$packages = & 'dism' '/English' \"/image:$($ScratchDisk)\\scratchdir\" '/Get-ProvisionedAppxPackages' |\r\n    ForEach-Object {\r\n        if ($_ -match 'PackageName : (.*)') {\r\n            $matches[1]\r\n        }\r\n    }\r\n\r\n$packagePrefixes = 'AppUp.IntelManagementandSecurityStatus',\r\n'Clipchamp.Clipchamp', \r\n'DolbyLaboratories.DolbyAccess',\r\n'DolbyLaboratories.DolbyDigitalPlusDecoderOEM',\r\n'Microsoft.BingNews',\r\n'Microsoft.BingSearch',\r\n'Microsoft.BingWeather',\r\n'Microsoft.Copilot',\r\n'Microsoft.Windows.CrossDevice',\r\n'Microsoft.GamingApp',\r\n'Microsoft.GetHelp',\r\n'Microsoft.Getstarted',\r\n'Microsoft.Microsoft3DViewer',\r\n'Microsoft.MicrosoftOfficeHub',\r\n'Microsoft.MicrosoftSolitaireCollection',\r\n'Microsoft.MicrosoftStickyNotes',\r\n'Microsoft.MixedReality.Portal',\r\n'Microsoft.MSPaint',\r\n'Microsoft.Office.OneNote',\r\n'Microsoft.OfficePushNotificationUtility',\r\n'Microsoft.OutlookForWindows',\r\n'Microsoft.Paint',\r\n'Microsoft.People',\r\n'Microsoft.PowerAutomateDesktop',\r\n'Microsoft.SkypeApp',\r\n'Microsoft.StartExperiencesApp',\r\n'Microsoft.Todos',\r\n'Microsoft.Wallet',\r\n'Microsoft.Windows.DevHome',\r\n'Microsoft.Windows.Copilot',\r\n'Microsoft.Windows.Teams',\r\n'Microsoft.WindowsAlarms',\r\n'Microsoft.WindowsCamera',\r\n'microsoft.windowscommunicationsapps',\r\n'Microsoft.WindowsFeedbackHub',\r\n'Microsoft.WindowsMaps',\r\n'Microsoft.WindowsSoundRecorder',\r\n'Microsoft.WindowsTerminal',\r\n'Microsoft.Xbox.TCUI',\r\n'Microsoft.XboxApp',\r\n'Microsoft.XboxGameOverlay',\r\n'Microsoft.XboxGamingOverlay',\r\n'Microsoft.XboxIdentityProvider',\r\n'Microsoft.XboxSpeechToTextOverlay',\r\n'Microsoft.YourPhone',\r\n'Microsoft.ZuneMusic',\r\n'Microsoft.ZuneVideo',\r\n'MicrosoftCorporationII.MicrosoftFamily',\r\n'MicrosoftCorporationII.QuickAssist',\r\n'MSTeams',\r\n'MicrosoftTeams', \r\n'Microsoft.WindowsTerminal',\r\n'Microsoft.549981C3F5F10'\r\n\r\n$packagesToRemove = $packages | Where-Object {\r\n    $packageName = $_\r\n    $packagePrefixes -contains ($packagePrefixes | Where-Object { $packageName -like \"*$_*\" })\r\n}\r\nforeach ($package in $packagesToRemove) {\r\n    & 'dism' '/English' \"/image:$($ScratchDisk)\\scratchdir\" '/Remove-ProvisionedAppxPackage' \"/PackageName:$package\"\r\n}\r\n\r\nWrite-Output \"Removing Edge:\"\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\\Program Files (x86)\\Microsoft\\Edge\" -Recurse -Force | Out-Null\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\\Program Files (x86)\\Microsoft\\EdgeUpdate\" -Recurse -Force | Out-Null\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\\Program Files (x86)\\Microsoft\\EdgeCore\" -Recurse -Force | Out-Null\r\n& 'takeown' '/f' \"$ScratchDisk\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" '/r' | Out-Null\r\n& 'icacls' \"$ScratchDisk\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" '/grant' \"$($adminGroup.Value):(F)\" '/T' '/C' | Out-Null\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\\Windows\\System32\\Microsoft-Edge-Webview\" -Recurse -Force | Out-Null\r\nWrite-Output \"Removing OneDrive:\"\r\n& 'takeown' '/f' \"$ScratchDisk\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" | Out-Null\r\n& 'icacls' \"$ScratchDisk\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" '/grant' \"$($adminGroup.Value):(F)\" '/T' '/C' | Out-Null\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\\Windows\\System32\\OneDriveSetup.exe\" -Force | Out-Null\r\nWrite-Output \"Removal complete!\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Output \"Loading registry...\"\r\nreg load HKLM\\zCOMPONENTS $ScratchDisk\\scratchdir\\Windows\\System32\\config\\COMPONENTS | Out-Null\r\nreg load HKLM\\zDEFAULT $ScratchDisk\\scratchdir\\Windows\\System32\\config\\default | Out-Null\r\nreg load HKLM\\zNTUSER $ScratchDisk\\scratchdir\\Users\\Default\\ntuser.dat | Out-Null\r\nreg load HKLM\\zSOFTWARE $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SOFTWARE | Out-Null\r\nreg load HKLM\\zSYSTEM $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SYSTEM | Out-Null\r\nWrite-Output \"Bypassing system requirements(on the system image):\"\r\nSet-RegistryValue 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassCPUCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassRAMCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassSecureBootCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassStorageCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassTPMCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\MoSetup' 'AllowUpgradesWithUnsupportedTPMOrCPU' 'REG_DWORD' '1'\r\nWrite-Output \"Disabling Sponsored Apps:\"\r\nSet-RegistryValue 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'OemPreInstalledAppsEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'PreInstalledAppsEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SilentInstalledAppsEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' 'DisableWindowsConsumerFeatures' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'ContentDeliveryAllowed' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\PolicyManager\\current\\device\\Start' 'ConfigureStartPins' 'REG_SZ' '{\"pinnedList\": [{}]}'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'FeatureManagementEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'PreInstalledAppsEverEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SoftLandingEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContentEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-310093Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-338388Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-338389Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-338393Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-353694Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SubscribedContent-353696Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager' 'SystemPaneSuggestionsEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\PushToInstall' 'DisablePushToInstall' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\MRT' 'DontOfferThroughWUAU' 'REG_DWORD' '1'\r\nRemove-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\\Subscriptions'\r\nRemove-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\ContentDeliveryManager\\SuggestedApps'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' 'DisableConsumerAccountStateContent' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\CloudContent' 'DisableCloudOptimizedContent' 'REG_DWORD' '1'\r\nWrite-Output \"Enabling Local Accounts on OOBE:\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\OOBE' 'BypassNRO' 'REG_DWORD' '1'\r\nCopy-Item -Path \"$PSScriptRoot\\autounattend.xml\" -Destination \"$ScratchDisk\\scratchdir\\Windows\\System32\\Sysprep\\autounattend.xml\" -Force | Out-Null\r\n\r\nWrite-Output \"Disabling Reserved Storage:\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\ReserveManager' 'ShippedWithReserves' 'REG_DWORD' '0'\r\nWrite-Output \"Disabling BitLocker Device Encryption\"\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\ControlSet001\\Control\\BitLocker' 'PreventDeviceEncryption' 'REG_DWORD' '1'\r\nWrite-Output \"Disabling Chat icon:\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Windows Chat' 'ChatIcon' 'REG_DWORD' '3'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced' 'TaskbarMn' 'REG_DWORD' '0'\r\nWrite-Output \"Removing Edge related registries\"\r\nRemove-RegistryValue \"HKEY_LOCAL_MACHINE\\zSOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge\"\r\nRemove-RegistryValue \"HKEY_LOCAL_MACHINE\\zSOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Microsoft Edge Update\"\r\nWrite-Output \"Disabling OneDrive folder backup\"\r\nSet-RegistryValue \"HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\OneDrive\" \"DisableFileSyncNGSC\" \"REG_DWORD\" \"1\"\r\nWrite-Output \"Disabling Telemetry:\"\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\AdvertisingInfo' 'Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Windows\\CurrentVersion\\Privacy' 'TailoredExperiencesWithDiagnosticDataEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Speech_OneCore\\Settings\\OnlineSpeechPrivacy' 'HasAccepted' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Input\\TIPC' 'Enabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization' 'RestrictImplicitInkCollection' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization' 'RestrictImplicitTextCollection' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\InputPersonalization\\TrainedDataStore' 'HarvestContacts' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Software\\Microsoft\\Personalization\\Settings' 'AcceptedPrivacyPolicy' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\DataCollection' 'AllowTelemetry' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\ControlSet001\\Services\\dmwappushservice' 'Start' 'REG_DWORD' '4'\r\n## Prevents installation of DevHome and Outlook\r\nWrite-Output \"Prevents installation of DevHome and Outlook:\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Orchestrator\\UScheduler\\OutlookUpdate' 'workCompleted' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Orchestrator\\UScheduler\\DevHomeUpdate' 'workCompleted' 'REG_DWORD' '1'\r\nRemove-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\OutlookUpdate'\r\nRemove-RegistryValue 'HKLM\\zSOFTWARE\\Microsoft\\WindowsUpdate\\Orchestrator\\UScheduler_Oobe\\DevHomeUpdate'\r\nWrite-Output \"Disabling Copilot\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\WindowsCopilot' 'TurnOffWindowsCopilot' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Edge' 'HubsSidebarEnabled' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Explorer' 'DisableSearchBoxSuggestions' 'REG_DWORD' '1'\r\nWrite-Output \"Prevents installation of Teams:\"\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Teams' 'DisableInstallation' 'REG_DWORD' '1'\r\nWrite-Output \"Prevent installation of New Outlook\":\r\nSet-RegistryValue 'HKLM\\zSOFTWARE\\Policies\\Microsoft\\Windows\\Windows Mail' 'PreventRun' 'REG_DWORD' '1'\r\n\r\nWrite-Host \"Deleting scheduled task definition files...\"\r\n$tasksPath = \"$ScratchDisk\\scratchdir\\Windows\\System32\\Tasks\"\r\n\r\n# Application Compatibility Appraiser\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Application Experience\\Microsoft Compatibility Appraiser\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Customer Experience Improvement Program (removes the entire folder and all tasks within it)\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Customer Experience Improvement Program\" -Recurse -Force -ErrorAction SilentlyContinue\r\n\r\n# Program Data Updater\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Application Experience\\ProgramDataUpdater\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Chkdsk Proxy\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Chkdsk\\Proxy\" -Force -ErrorAction SilentlyContinue\r\n\r\n# Windows Error Reporting (QueueReporting)\r\nRemove-Item -Path \"$tasksPath\\Microsoft\\Windows\\Windows Error Reporting\\QueueReporting\" -Force -ErrorAction SilentlyContinue\r\nWrite-Host \"Task files have been deleted.\"\r\nWrite-Host \"Unmounting Registry...\"\r\nreg unload HKLM\\zCOMPONENTS | Out-Null\r\nreg unload HKLM\\zDEFAULT | Out-Null\r\nreg unload HKLM\\zNTUSER | Out-Null\r\nreg unload HKLM\\zSOFTWARE | Out-Null\r\nreg unload HKLM\\zSYSTEM | Out-Null\r\nWrite-Output \"Cleaning up image...\"\r\ndism.exe /Image:$ScratchDisk\\scratchdir /Cleanup-Image /StartComponentCleanup /ResetBase\r\nWrite-Output \"Cleanup complete.\"\r\nWrite-Output ' '\r\nWrite-Output \"Unmounting image...\"\r\nDismount-WindowsImage -Path $ScratchDisk\\scratchdir -Save\r\nWrite-Host \"Exporting image...\"\r\nDism.exe /Export-Image /SourceImageFile:\"$ScratchDisk\\tiny11\\sources\\install.wim\" /SourceIndex:$index /DestinationImageFile:\"$ScratchDisk\\tiny11\\sources\\install2.wim\" /Compress:recovery\r\nRemove-Item -Path \"$ScratchDisk\\tiny11\\sources\\install.wim\" -Force | Out-Null\r\nRename-Item -Path \"$ScratchDisk\\tiny11\\sources\\install2.wim\" -NewName \"install.wim\" | Out-Null\r\nWrite-Output \"Windows image completed. Continuing with boot.wim.\"\r\nStart-Sleep -Seconds 2\r\nClear-Host\r\nWrite-Output \"Mounting boot image:\"\r\n$wimFilePath = \"$ScratchDisk\\tiny11\\sources\\boot.wim\"\r\n& takeown \"/F\" $wimFilePath | Out-Null\r\n& icacls $wimFilePath \"/grant\" \"$($adminGroup.Value):(F)\"\r\nSet-ItemProperty -Path $wimFilePath -Name IsReadOnly -Value $false\r\nMount-WindowsImage -ImagePath $ScratchDisk\\tiny11\\sources\\boot.wim -Index 2 -Path $ScratchDisk\\scratchdir\r\nWrite-Output \"Loading registry...\"\r\nreg load HKLM\\zCOMPONENTS $ScratchDisk\\scratchdir\\Windows\\System32\\config\\COMPONENTS\r\nreg load HKLM\\zDEFAULT $ScratchDisk\\scratchdir\\Windows\\System32\\config\\default\r\nreg load HKLM\\zNTUSER $ScratchDisk\\scratchdir\\Users\\Default\\ntuser.dat\r\nreg load HKLM\\zSOFTWARE $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SOFTWARE\r\nreg load HKLM\\zSYSTEM $ScratchDisk\\scratchdir\\Windows\\System32\\config\\SYSTEM\r\n\r\nWrite-Output \"Bypassing system requirements(on the setup image):\"\r\nSet-RegistryValue 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zDEFAULT\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV1' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zNTUSER\\Control Panel\\UnsupportedHardwareNotificationCache' 'SV2' 'REG_DWORD' '0'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassCPUCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassRAMCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassSecureBootCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassStorageCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\LabConfig' 'BypassTPMCheck' 'REG_DWORD' '1'\r\nSet-RegistryValue 'HKLM\\zSYSTEM\\Setup\\MoSetup' 'AllowUpgradesWithUnsupportedTPMOrCPU' 'REG_DWORD' '1'\r\nWrite-Output \"Tweaking complete!\"\r\n\r\nWrite-Output \"Unmounting Registry...\"\r\nreg unload HKLM\\zCOMPONENTS | Out-Null\r\nreg unload HKLM\\zDEFAULT | Out-Null\r\nreg unload HKLM\\zNTUSER | Out-Null\r\nreg unload HKLM\\zSOFTWARE | Out-Null\r\nreg unload HKLM\\zSYSTEM | Out-Null\r\n\r\nWrite-Output \"Unmounting image...\"\r\nDismount-WindowsImage -Path $ScratchDisk\\scratchdir -Save\r\nClear-Host\r\nWrite-Output \"The tiny11 image is now completed. Proceeding with the making of the ISO...\"\r\nWrite-Output \"Copying unattended file for bypassing MS account on OOBE...\"\r\nCopy-Item -Path \"$PSScriptRoot\\autounattend.xml\" -Destination \"$ScratchDisk\\tiny11\\autounattend.xml\" -Force | Out-Null\r\nWrite-Output \"Creating ISO image...\"\r\n$ADKDepTools = \"C:\\Program Files (x86)\\Windows Kits\\10\\Assessment and Deployment Kit\\Deployment Tools\\$hostarchitecture\\Oscdimg\"\r\n$localOSCDIMGPath = \"$PSScriptRoot\\oscdimg.exe\"\r\n\r\nif ([System.IO.Directory]::Exists($ADKDepTools)) {\r\n    Write-Output \"Will be using oscdimg.exe from system ADK.\"\r\n    $OSCDIMG = \"$ADKDepTools\\oscdimg.exe\"\r\n} else {\r\n    Write-Output \"ADK folder not found. Will be using bundled oscdimg.exe.\"\r\n    $url = \"https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe\"\r\n\r\n    if (-not (Test-Path -Path $localOSCDIMGPath)) {\r\n        Write-Output \"Downloading oscdimg.exe...\"\r\n        Invoke-WebRequest -Uri $url -OutFile $localOSCDIMGPath\r\n\r\n        if (Test-Path $localOSCDIMGPath) {\r\n            Write-Output \"oscdimg.exe downloaded successfully.\"\r\n        } else {\r\n            Write-Error \"Failed to download oscdimg.exe.\"\r\n            exit 1\r\n        }\r\n    } else {\r\n        Write-Output \"oscdimg.exe already exists locally.\"\r\n    }\r\n\r\n    $OSCDIMG = $localOSCDIMGPath\r\n}\r\n\r\n& \"$OSCDIMG\" '-m' '-o' '-u2' '-udfver102' \"-bootdata:2#p0,e,b$ScratchDisk\\tiny11\\boot\\etfsboot.com#pEF,e,b$ScratchDisk\\tiny11\\efi\\microsoft\\boot\\efisys.bin\" \"$ScratchDisk\\tiny11\" \"$PSScriptRoot\\tiny11.iso\"\r\n\r\n# Finishing up\r\nWrite-Output \"Creation completed! Press any key to exit the script...\"\r\nRead-Host \"Press Enter to continue\"\r\nWrite-Output \"Performing Cleanup...\"\r\nRemove-Item -Path \"$ScratchDisk\\tiny11\" -Recurse -Force | Out-Null\r\nRemove-Item -Path \"$ScratchDisk\\scratchdir\" -Recurse -Force | Out-Null\r\nWrite-Output \"Ejecting Iso drive\"\r\nGet-Volume -DriveLetter $DriveLetter[0] | Get-DiskImage | Dismount-DiskImage\r\nWrite-Output \"Iso drive ejected\"\r\nWrite-Output \"Removing oscdimg.exe...\"\r\nRemove-Item -Path \"$PSScriptRoot\\oscdimg.exe\" -Force -ErrorAction SilentlyContinue\r\nWrite-Output \"Removing autounattend.xml...\"\r\nRemove-Item -Path \"$PSScriptRoot\\autounattend.xml\" -Force -ErrorAction SilentlyContinue\r\n\r\nWrite-Output \"Cleanup check :\"\r\nif (Test-Path -Path \"$ScratchDisk\\tiny11\") {\r\n    Write-Output \"tiny11 folder still exists. Attempting to remove it again...\"\r\n    Remove-Item -Path \"$ScratchDisk\\tiny11\" -Recurse -Force -ErrorAction SilentlyContinue\r\n    if (Test-Path -Path \"$ScratchDisk\\tiny11\") {\r\n        Write-Output \"Failed to remove tiny11 folder.\"\r\n    } else {\r\n        Write-Output \"tiny11 folder removed successfully.\"\r\n    }\r\n} else {\r\n    Write-Output \"tiny11 folder does not exist. No action needed.\"\r\n}\r\nif (Test-Path -Path \"$ScratchDisk\\scratchdir\") {\r\n    Write-Output \"scratchdir folder still exists. Attempting to remove it again...\"\r\n    Remove-Item -Path \"$ScratchDisk\\scratchdir\" -Recurse -Force -ErrorAction SilentlyContinue\r\n    if (Test-Path -Path \"$ScratchDisk\\scratchdir\") {\r\n        Write-Output \"Failed to remove scratchdir folder.\"\r\n    } else {\r\n        Write-Output \"scratchdir folder removed successfully.\"\r\n    }\r\n} else {\r\n    Write-Output \"scratchdir folder does not exist. No action needed.\"\r\n}\r\nif (Test-Path -Path \"$PSScriptRoot\\oscdimg.exe\") {\r\n    Write-Output \"oscdimg.exe still exists. Attempting to remove it again...\"\r\n    Remove-Item -Path \"$PSScriptRoot\\oscdimg.exe\" -Force -ErrorAction SilentlyContinue\r\n    if (Test-Path -Path \"$PSScriptRoot\\oscdimg.exe\") {\r\n        Write-Output \"Failed to remove oscdimg.exe.\"\r\n    } else {\r\n        Write-Output \"oscdimg.exe removed successfully.\"\r\n    }\r\n} else {\r\n    Write-Output \"oscdimg.exe does not exist. No action needed.\"\r\n}\r\nif (Test-Path -Path \"$PSScriptRoot\\autounattend.xml\") {\r\n    Write-Output \"autounattend.xml still exists. Attempting to remove it again...\"\r\n    Remove-Item -Path \"$PSScriptRoot\\autounattend.xml\" -Force -ErrorAction SilentlyContinue\r\n    if (Test-Path -Path \"$PSScriptRoot\\autounattend.xml\") {\r\n        Write-Output \"Failed to remove autounattend.xml.\"\r\n    } else {\r\n        Write-Output \"autounattend.xml removed successfully.\"\r\n    }\r\n} else {\r\n    Write-Output \"autounattend.xml does not exist. No action needed.\"\r\n}\r\n\r\n# Stop the transcript\r\nStop-Transcript\r\n\r\nexit\r\n\r\n"
  }
]