Skip to content

Instantly share code, notes, and snippets.

@AlphaKR93
Last active October 20, 2024 01:28
Show Gist options
  • Save AlphaKR93/73aadf32a18507dda310bf1e7d871178 to your computer and use it in GitHub Desktop.
Save AlphaKR93/73aadf32a18507dda310bf1e7d871178 to your computer and use it in GitHub Desktop.
Micro11 Image Creator

Micro11 Image Creator

Micro11(Core11) is a fork of tiny11builder by NTDEV.

Micro11 is a Windows installation media that removes unnecessary packages and features of Windows 11.
It is an open-source and can be created directly by the official ISO, so (at least) the image is not exposed to hacking.

Differences between Micro11 and Tiny11

In most cases, there are none except when the script is executed.
Micro11 was forked just to easily control the changes applied by Tiny11 as script parameters, and in fact, the changes applied to the image are almost the same, except for some parts of answer file and registry.

There are significant differences in the execution process of the script. A progress bar is displayed for each operation, and you can directly modify the configuration of the pre-build image. Most of the progress is done through PowerShell commands, and all progress is saved in more detail in the log file.

<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Diagnostics>
<OptIn>false</OptIn>
</Diagnostics>
<DynamicUpdate>
<Enable>false</Enable>
<WillShowUI>Never</WillShowUI>
</DynamicUpdate>
<ImageInstall>
<OSImage>
<Compact>true</Compact>
</OSImage>
</ImageInstall>
<UserData>
<AcceptEula>true</AcceptEula>
</UserData>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Reseal>
<Mode>OOBE</Mode>
</Reseal>
</component>
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
<ConfigureChatAutoInstall>False</ConfigureChatAutoInstall>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<Order>1</Order>
<CommandLine>powershell.exe -NoProfile -Command "Disable-ComputerRestore -Drive 'C:\';"</CommandLine>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideLocalAccountScreen>false</HideLocalAccountScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<ProtectYourPC>3</ProtectYourPC>
<NetworkLocation>Home</NetworkLocation>
</OOBE>
<WindowsFeatures>
<ShowInternetExplorer>false</ShowInternetExplorer>
<ShowMediaCenter>false</ShowMediaCenter>
<ShowWindowsMediaPlayer>false</ShowWindowsMediaPlayer>
</WindowsFeatures>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Disk-Failure-Diagnostic-Module" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<EnabledScenarioExecutionLevel>1</EnabledScenarioExecutionLevel>
</component>
<component name="Microsoft-Windows-ErrorReportingCore" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisableWER>1</DisableWER>
</component>
<component name="Microsoft-Windows-Printing-Spooler-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RemoveMXDW>1</RemoveMXDW>
</component>
<component name="Microsoft-Windows-SQMAPI" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<CEIPEnabled>0</CEIPEnabled>
</component>
<component name="Microsoft-Windows-SystemRestore-Main" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DisableSR>1</DisableSR>
</component>
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RunSynchronous>
<RunSynchronousCommand wcm:action="add">
<Order>1</Order>
<Path>icacls.exe C:\ /remove:g "*S-1-5-11"</Path>
</RunSynchronousCommand>
<RunSynchronousCommand wcm:action="add">
<Order>2</Order>
<Path>powercfg.exe -duplicatescheme e9a42b02-d5df-448d-aa00-03f14749eb61</Path>
</RunSynchronousCommand>
</RunSynchronous>
</component>
</settings>
</unattend>
$user = "AlphaKR93"; $target = "73aadf32a18507dda310bf1e7d871178"; $privilege = $true; $windowStyle = "Maximized"
iwr 'https://gist.githubusercontent.com/AlphaKR93/79d24156e5a20595221d1b58db474fcc/raw/invoke.ps1' | iex
param (
# AppX Packages to remove
[Parameter(Mandatory = $false)]
[string[]] $AppxTBR = @(
'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.ZuneMusic'
'Microsoft.ZuneVideo'
'Microsoft.Windows.Ai.Copilot.Provider'
'MicrosoftCorporationII.MicrosoftFamily'
'MicrosoftCorporationII.QuickAssist'
'MicrosoftTeams'
'Microsoft.549981C3F5F10'
),
# Windows Capabilities to remove
[Parameter(Mandatory = $false)]
[string[]] $CapsTBR = @(
'Microsoft.Windows.Wifi.Client.Broadcom.Bcmpciedhd63'
'Microsoft.Windows.Wifi.Client.Broadcom.Bcmwl63al'
'Microsoft.Windows.Wifi.Client.Broadcom.Bcmwl63a'
'Microsoft.Windows.Wifi.Client.Intel.Netwbw02'
'Microsoft.Windows.Wifi.Client.Intel.Netwew00'
'Microsoft.Windows.Wifi.Client.Intel.Netwew01'
'Microsoft.Windows.Wifi.Client.Intel.Netwlv64'
'Microsoft.Windows.Wifi.Client.Intel.Netwns64'
'Microsoft.Windows.Wifi.Client.Intel.Netwsw00'
'Microsoft.Windows.Wifi.Client.Intel.Netwtw02'
'Microsoft.Windows.Wifi.Client.Intel.Netwtw04'
'Microsoft.Windows.Wifi.Client.Intel.Netwtw06'
'Microsoft.Windows.Wifi.Client.Intel.Netwtw08'
'Microsoft.Windows.Wifi.Client.Intel.Netwtw10'
'Microsoft.Windows.Wifi.Client.Marvel.Mrvlpcie8897'
'Microsoft.Windows.Wifi.Client.Qualcomm.Athw8x'
'Microsoft.Windows.Wifi.Client.Qualcomm.Athwnx'
'Microsoft.Windows.Wifi.Client.Qualcomm.Qcamain10x64'
'Microsoft.Windows.Wifi.Client.Ralink.Netr28x'
'Microsoft.Windows.Wifi.Client.Realtek.Rtl8187se'
'Microsoft.Windows.Wifi.Client.Realtek.Rtl8192se'
'Microsoft.Windows.Wifi.Client.Realtek.Rtl819xp'
'Microsoft.Windows.Wifi.Client.Realtek.Rtl85n64'
'Microsoft.Windows.Wifi.Client.Realtek.Rtwlane01'
'Microsoft.Windows.Wifi.Client.Realtek.Rtwlane13'
'Microsoft.Windows.Wifi.Client.Realtek.Rtwlane'
'Microsoft.Windows.Ethernet.Client.Intel.E1i68x64'
'Microsoft.Windows.Ethernet.Client.Intel.E2f68'
'Microsoft.Windows.Ethernet.Client.Realtek.Rtcx21x64'
'Microsoft.Windows.Ethernet.Client.Vmware.Vmxnet3'
'App.StepsRecorder'
'Brower.InternetExplorer'
'Hello.Face'
'Language.Handwriting'
'Language.OCR'
'Language.Speech'
'Language.TextToSpeech'
'MathRecognizer'
'Media.WindowsMediaPlayer'
'Microsoft.Wallpapers.Extended'
'Microsoft.Windows.Notepad.System'
# 'Microsoft.Windows.PowerShell.ISE' # IDK, but access denied
),
# Windows Capabilities to add
[Parameter(Mandatory = $false)]
[string[]] $CapsTBA = @(),
# Optioanl Features to disable
[Parameter(Mandatory = $false)]
[string[]] $WOFsTBD = @(
'Printing-PrintToPDFServices-Features'
'SearchEngine-Client-Package'
'WorkFolders-Client'
'MediaPlayback'
'WindowsMediaPlayer'
# 'SmbDirect'
),
# Optional Features to enable
[Parameter(Mandatory = $false)]
[string[]] $WOFsTBE = @(
# 'NetFX3', # .NET 3.5. Uncomment if you want to enable this
),
<#
****############################################################################
****############################################################################
****##################### #####################
****##################### DO NOT EDIT AFTER THIS LINE !! #####################
****##################### #####################
****############################################################################
****############################################################################
#>
# Additional AppX Packages to remove
[Parameter(Mandatory = $false)] [Alias("rp")]
[string[]] $RemovePackage,
# Additional Windows Capabilities to add
[Parameter(Mandatory = $false)] [Alias("wc", "cap", "Capability", "WindowsCapability")]
[string[]] $AddCapability,
# Additional Windows Capabilities to remove
[Parameter(Mandatory = $false)] [Alias("rc")]
[string[]] $RemoveCapability,
# Additional Optional Features to enable
[Parameter(Mandatory = $false)] [Alias("of", "wof", "Feature", "OptionalFeature")]
[string[]] $EnableFeature,
# Additional Optional Features to disable
[Parameter(Mandatory = $false)] [Alias("rf", "rof")]
[string[]] $DisableFeature,
# Directory to store the files for the task, such as installation media contents
[Parameter(Mandatory = $false)]
[string] $WorkPath = "$pwd\micro11",
# Directory to mount windows image
[Parameter(Mandatory = $false)]
[string] $ScratchPath = "$Env:SystemDrive\scratch",
# Whether to skip ISO creation
[Parameter(Mandatory = $false)]
[switch] $SkipISO = $false,
# Whether to skip boot.wim (Setup) processing
[Parameter(Mandatory = $false)]
[switch] $SkipBoot = $false,
# Whether to apply aggressive optimization
[Parameter(Mandatory= $false)]
[switch] $MakeCore = $false,
# Whether to apply optimizations directly into the installation media
[Parameter(Mandatory= $false)]
[switch] $ApplyDirectly = $false,
# Disk letter of the image to be used as the source
[Parameter(Mandatory = $false)]
[string] $InstallMedia,
# Index of the image to be used as a source
[Parameter(Mandatory = $false)]
[int] $Index,
# Whether to print logs in realtime
[Parameter(Mandatory = $false)]
[switch] $Log,
[Parameter(Mandatory = $false)]
[switch] $DebugTrace,
[Parameter(Mandatory = $false)]
[int] $StartDebugAt,
[Parameter(Mandatory = $false)]
[int] $StopDebugAt,
# Whether to skip every prompt
[Parameter(Mandatory = $false)]
[switch] $y
)
if ($DebugTrace) { Set-PSDebug -Trace 1 }
if ($Log) { $InformationPreference = 'Continue' }
$ErrorActionPreference = "Stop"
Invoke-WebRequest 'https://gist.githubusercontent.com/AlphaKR93/79d24156e5a20595221d1b58db474fcc/raw/script.ps1' | Invoke-Expression
<#
###############################################################################
[ CHECK AND RUN THE SCRIPT AS ADMINISTRATOR IF REQUIRED ]
###############################################################################
#>
{
$adminSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-5-32-544")
$global:admins = $adminSID.Translate([System.Security.Principal.NTAccount])
$winID = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$winPrincipal = New-Object System.Security.Principal.WindowsPrincipal($winID)
if (!$winPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))
{
Write-Success "Restarting terminal as admin in a new window, you can close this one."
$sudo = New-Object System.Diagnostics.ProcessStartInfo("PowerShell")
$sudo.Arguments = $minvocation.MyCommand.Definition
$sudo.Verb = "runAs"
[System.Diagnostics.Process]::Start($sudo)
exit 0
}
}.Invoke()
<#
###############################################################################
[ CHECK IF THE OPTION IS CORRECT ]
###############################################################################
#>
$confirmed = $y
while (!$confirmed) {
if ($MakeCore) { $mode = "Core11" } else { $mode = "Micro11" }
if ($ApplyDirectly) { $mode += " directly" }
if ($SkipISO -or $SkipBoot) {
$mode += ", Skipping "
if ($SkipISO -and $SkipBoot) { $mode += "ISO and Boot" }
elseif ($SkipISO) { $mode += "ISO" }
elseif ($SkipBoot) { $mode += "Boot" }
}
Write-Status "Select the option you want to change. Enter 'C' to confirm."
Write-Notify "Package and feature options are displayed after image mount."
Write-Host " "
Write-Host "Creating $mode"
Write-Host "Work Path: $WorkPath"
Write-Host "Scratch Path: $ScratchPath"
Write-Host " "
Write-Host "A description of each option is available in Gist." -ForegroundColor DarkGray
switch (Read-Choices -Choice '&Mode', '&Apply Directly', 'Skip &ISO', 'Skip &Boot', '&Work Path', '&Scratch Path', '&Confirm' -Default 6) {
0 { $MakeCore = !$MakeCore }
1 { $ApplyDirectly = !$ApplyDirectly }
2 { $SkipISO = !$SkipISO }
3 { $SkipBoot = !$SkipBoot }
4 {
Clear-Host; Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$WorkPath = Read-Prompts "Enter the new work path" -DefaultValue $WorkPath
}
5 {
Clear-Host; Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$ScratchPath = Read-Prompts "Enter the new scratch path" -DefaultValue $ScratchPath
}
6 { $confirmed = $true }
}
}
<#
###############################################################################
[ START THE TRANSCRIPT AND PREPARE THE ENVIRONMENT ]
###############################################################################
#>
$BRANDING = "Micro11"
if ($MakeCore -and !$y) {
$BRANDING = "Core11"
$warnMessage = "
Core mode 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.
Core11 (original name is tiny11 core) is not a full Windows 11 substitute,
but a rapid testing or development tool, potentially useful for VM environments.
Are you sure you want to continue? [y/N]
"
if (0 -ne (Read-Choices "WARNING! Core mode is enabled!" -Content $warnMessage -Default 1)) {
Clear-Host
Write-Warning "The script was interrupted because an invalid key was entered or the user ordered cancellation."
Write-Error "The script could not continue. The script is terminated."
exit 0
}
Write-Status "Off we go..."
$AppxTBR += @(
'Microsoft.SecHealthUI'
'Microsoft.Windows.PeopleExperienceHost'
'Microsoft.Windows.PinningConfirmationDialog'
'Windows.CBSPreview'
)
$CapsTBR = @(
# 'Windows-Defender-Client-Package~31bf3856ad364e35~' # TODO: Change this
'Windows.Kernel.LA57'
'OpenSSH.Client'
'Print.Management.Console'
)
Start-Sleep -Seconds 2
Clear-Host
}
$Host.UI.RawUI.WindowTitle = "$BRANDING Image Creator"
New-Item -ItemType Directory -Force -Path "$WorkPath" -Verbose
New-Item -ItemType Directory -Force -Path "$ScratchPath" -Verbose
try { Start-Transcript -Path "$WorkPath\micro11.log" }
catch {
if ($_.FullyQualifiedErrorId -ne "CannotStartTranscription,Microsoft.PowerShell.Commands.StartTranscriptCommand") {
throw $_
}
Start-Transcript -Path "$WorkPath\micro11.log"
}
$FSAR = New-Object System.Security.AccessControl.FileSystemAccessRule($admins, "FullControl", "ContainerInherit, ObjectInherit", "None", "Allow")
$regAR = New-Object System.Security.AccessControl.RegistryAccessRule($admins, "FullControl", "ContainerInherit", "None", "Allow")
$Step = 0
Clear-Host
<#
###############################################################################
[ RESOLVE THE INSTALLATION MEDIA DISK ]
###############################################################################
#>
Invoke-Safely "Resolve the installation media disk" {
if ("" -eq $InstallMedia) {
$InstallMedia = Read-Host "Please enter the disk letter of Windows 11 Installation Media"
}
$InstallMedia = $InstallMedia + ":";
if (Test-Path -Path "$InstallMedia\sources\install.wim") { $srcType = "wim" }
elseif (Test-Path -Path "$InstallMedia\sources\install.esd") { $srcType = "esd" }
else {
Write-Error "Unable to find Windows Installation Media files in the specified disk.`nMake sure you entered the correct disk letter."
throw "Invalid installation media disk entered"
}
if ($ApplyDirectly) {
if ((Get-ItemProperty -Path "$InstallMedia\sources\install.$srcType").IsReadOnly) {
Write-Error "You have enabled direct optimization, but the specified disk is read-only.`nPlease enter the installation media disk that can be written."
throw "Attempt to write to read-only installation media"
}
if (0 -ne (Read-Choices "WARNING! Direct Optimization is enabled!" `
-Content "We will not be responsible for any problems with the installation media.`nAre you sure you want to continue? [y/N]" `
-Default 1
)) {
Clear-Host
Write-Warning "The script was interrupted because an invalid key was entered or the user ordered cancellation."
Write-Error "The script could not continue. The script is terminated."
exit 0
}
Write-Host "Off we go..."
}
$global:srcType = $srcType; $global:InstallMedia = $InstallMedia;
}
<#
###############################################################################
[ RESOLVE WINDOWS INSTALLTION IMAGE ]
###############################################################################
#>
Invoke-Safely "Resolve the source image" {
Write-Status "Getting image information..."
if ($ApplyDirectly) { $source = "$InstallMedia" }
else { $source = "$WorkPath\src" }
Write-Host "$InstallMedia\sources\install.$srcType"
$wimPath = "$source\sources\install.wim"
$wimInfo = Write-Result { Get-WindowsImage -ImagePath "$InstallMedia\sources\install.$srcType" }
if (0 -gt $wimInfo.Length) { throw "Detected corrupted installation image" }
if (1 -eq $wimInfo.Length) { $Index = 1; return }
if (0 -eq $Index)
{
$selections = $wimInfo | ForEach-Object { "&$($_.ImageIndex): $($_.ImageName)" }
$Index = (Read-Choices "Select the image to use as the source" -Content ($wimInfo | Out-String) -Choice $selections) + 1
}
if ($Index -notin ($wimInfo | Foreach-Object ImageIndex))
{
Write-Warning "Unable to find the specified image in the install.$srcType"
Write-Warning "Please enter the correct image index."
throw "Invalid image index entered"
}
$global:source = $source; $global:wimPath = $wimPath; $global:wimInfo = $wimInfo; $global:Index = $Index;
}
<#
###############################################################################
[ UNLOAD PREVIOUSLY LOADED REGISTRY HIVES IF REQUIRED ]
###############################################################################
This section always runs when the image is mounted, regardless of where it starts.
This is because DISM does not work correctly with the registry hive loaded.
#>
$mountedPreviously = 0 -lt (Get-WindowsImage -Mounted | Where-Object { ("$ScratchPath" -eq $_.Path) -or ("$wimPath" -eq $_.ImagePath) }).Length
Invoke-Safely -When { $mountedPreviously } "Unload previously loaded registry hives" {
Write-Status "Checking if the registry hives are loaded..."
$live = @('DRV', 'SCM', 'COM', 'DEF', 'USR', 'SFT', 'SYS') | Where-Object { Test-Path -Path "HKLM:\MICRO11_$_" }
if (0 -eq $live.Length) {
Write-Success "Loaded registry hives have not been detected, continuing..."
return
}
$live | ForEach-Object { Write-Result { & 'reg' 'unload' "HKLM\MICRO11_$_" } > $null }
Write-Success "Unload complete!"
}
Invoke-Safely -When { $mountedPreviously } -Id (++$Step) "Unmount previously mounted image" {
Write-Status "Unmounting previously mounted image... Please wait"
Dismount-WindowsImage -Path "$ScratchPath" -Discard > $null
Write-Success "Unmount complete!"
}
<#
###############################################################################
[ ASK FOR ADDITIONAL OPTION EDIT ]
###############################################################################
#>
$AppxTBR += $RemovePackage
$CapsTBA += $AddCapability
$CapsTBR += $RemoveCapability
$WOFsTBE += $EnableFeature
$WOFsTBD += $DisableFeature
Invoke-Safely -When { !$y } "Ask for additional option edit" {
if (0 -ne (Read-Choices "Do you want to modify the build options?")) { return }
Write-Status "Mounting image with readonly... Please wait"
Mount-WindowsImage -ImagePath "$InstallMedia\sources\install.$srcType" -Index $Index -Path "$ScratchPath" -ReadOnly > $null
$availablePkgs = Get-ProvisionedAppxPackage -Path "$ScratchPath"
$availableCaps = Get-WindowsCapability -Path "$ScratchPath"
$installedCaps = $availableCaps | Where-Object { 'Installed' -eq $_.State }
$installableCaps = $availableCaps | Where-Object { 'NotPresent' -eq $_.State }
$availableWOFs = Get-WindowsOptionalFeature -Path "$ScratchPath"
$enabledWOFs = $availableWOFs | Where-Object { 'Enabled' -eq $_.State }
$disabledWOFs = $availableWOFs | Where-Object { 'Disabled' -eq $_.State }
Write-Success "Mount complete!"
$promptRemPkgs = {
Write-Status "Please enter the provisioned packages that you want to remove." -Success
Write-Host "Separate them with spaces."
Write-Host " "
Write-Notify "Currently available provisioned packages are:"
$availablePkgs | Format-Wide -Property DisplayName -AutoSize | Out-Host
Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$global:AppxTBR = @(Read-Prompts "Packages to remove" -DefaultValue "$AppxTBR")
}
$promptAddCaps = {
Write-Status "Please enter the Windows Capabilities you want to add." -Success
Write-Host "Separate them with spaces."
Write-Host " "
Write-Notify "Currently available Windows Capabilities are:"
$installableCaps | Format-Wide -Property Name -AutoSize | Out-Host
Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$global:CapsTBA = @(Read-Prompts "Capabilities to add" -DefaultValue "$CapsTBA")
}
$promptRemCaps = {
Write-Status "Please enter the Windows Capabilities you want to remove." -Success
Write-Host "Separate them with spaces."
Write-Host " "
Write-Notify "Currently available Windows Capabilities are:"
$installedCaps | Format-Wide -Property Name -AutoSize | Out-Host
Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$global:CapsTBR = @(Read-Prompts "Capabilities to remove" -DefaultValue "$CapsTBR")
}
$promptWOFsON = {
Write-Status "Please enter the Optional Features you want to enable." -Success
Write-Host "Separate them with spaces."
Write-Host " "
Write-Notify "Currently available Optional Features are:"
$disabledWOFs | Format-Wide -Property FeatureName -AutoSize | Out-Host
Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$global:WOFsTBE = @(Read-Prompts "Features to enable" -DefaultValue "$WOFsTBE")
}
$promptWOFsOFF = {
Write-Status "Please enter the Optional Features you want to disable." -Success
Write-Host "Separate them with spaces."
Write-Host " "
Write-Notify "Currently available Optional Features are:"
$enabledWOFs | Format-Wide -Property FeatureName -AutoSize | Out-Host
Write-Host "Don't do anything until you see the prompt!" -ForegroundColor DarkYellow
$global:WOFsTBD = @(Read-Prompts "Features to disable" -DefaultValue "$WOFsTBD")
}
while ($true) {
Clear-Host
Write-Notify "AppX Packages to be removed"
Write-Host "$AppxTBR"
Write-Notify "Windows Capabilities to be added"
Write-Host "$CapsTBA"
Write-Notify "Windows Capabilities to be removed"
Write-Host "$CapsTBR"
Write-Notify "Optional Features to be enabled"
Write-Host "$WOFsTBE"
Write-Notify "Optional Packages to be disabled"
Write-Host "$WOFsTBD"
switch (
Read-Choices "Select the value you want to modify. Confirm as 'C'." `
-Choice '&Packages to Remove', 'Capabilities to &Add', 'Capabilities to &Remove', 'Features to &Enable', 'Features to &Disable', '&Confirm' `
-Default 5
) {
0 { $promptRemPkgs.Invoke() }
1 { $promptAddCaps.Invoke() }
2 { $promptRemCaps.Invoke() }
3 { $promptWOFsON.Invoke() }
4 { $promptWOFsOFF.Invoke() }
5 {
Write-Status "Unmounting image... Please wait"
Dismount-WindowsImage -Path "$ScratchPath" -Discard > $null
return
}
}
}
}
$AppxTBR = $AppxTBR.Split(' ')
$CapsTBA = $CapsTBA.Split(' ')
$CapsTBR = $CapsTBR.Split(' ')
$WOFsTBE = $WOFsTBE.Split(' ')
$WOFsTBD = $WOFsTBD.Split(' ')
<#
###############################################################################
[ CLEAN UP FILES PREVIOUSLY USED IN THE SCRIPT ]
###############################################################################
#>
Invoke-Safely -Id (++$Step) `
-When { !$ApplyDirectly -and (Test-Path -Path "$source") } `
"Cleanup files which previously used in the script" {
Write-Status "Removing files previously used in the script..."
Remove-ItemWithProgress -Path "$source" > $null
Write-Success "Removal complete!"
}
<#
###############################################################################
[ COPY THE INSTALLATION MEDIA CONTENTS INTO WORK DIRECTORY ]
###############################################################################
#>
Invoke-Safely -Id (++$Step) `
-When { !$ApplyDirectly -and ('esd' -eq $srcType) } `
"Convert ESD to WIM" {
Write-Status "Found install.esd, converting to wim..."
New-Item -Path "$source\sources" -ItemType Directory -Force > $null
Export-WindowsImage `
-SourceImagePath "$InstallMedia\sources\install.esd" `
-SourceIndex $Index `
-DestinationImagePath "$wimPath" `
-CompressionType "max" `
-CheckIntegrity > $null
$global:Index = 1
Write-Success "Convert complete!"
}
Invoke-Safely -Id (++$Step) `
-When { !$ApplyDirectly } `
"Copy the installation media contents into work directory" {
Write-Status "Copying Windows installation media contents..."
New-Item -ItemType Directory -Force -Path "$source" > $null
Copy-ItemWithProgress `
-Path "$InstallMedia\*" `
-Destination "$source" `
-Exclude "install.esd" > $null
Write-Success "Copy complete!"
}
<#
###############################################################################
[ MOUNT SELECTED WINDOWS INSTALLATION IMAGE ]
###############################################################################
#>
Invoke-Safely "Getting selected image information" {
Write-Status "Getting selected image information..."
$global:imgInfo = Write-Result { Get-WindowsImage -ImagePath "$wimPath" -Index $Index }
$archType = switch ($imgInfo.Architecture)
{
0 { "x86", "x86" }
1 { "mips", "mips" }
2 { "alpha", "alpha" } # HOLY-
3 { "powerpc", "powerpc" }
5 { "arm", "arm" }
6 { "x86", "ia64" }
9 { "x86", "amd64" }
12 { "arm", "arm64" }
default { $null }
}
$global:baseArch = $archType[0]
$global:arch = $archType[1]
if ($null -ne $arch) { Write-Host "Architecture is: $arch" }
else { Write-Warning "Failed to detect image architecture, some optimizations will not be applied" }
$global:lang = $imgInfo.Languages[0]
Write-Host "Default system UI language code is: $lang"
}
Invoke-Safely -Id (++$Step) "Mount selected windows installation image" {
Write-Status "Mounting $($imgInfo.ImageName) source image. This may take a while."
Add-AccessRule -Path "$wimPath" -AccessRule $FSAR > $null
Set-ItemProperty -Path $wimPath -Name IsReadOnly -Value $false > $null
Mount-WindowsImage -ImagePath "$wimPath" -Index $Index -Path "$ScratchPath" > $null
Write-Success "Mount complete!"
}
<#
###############################################################################
[ REMOVE PROVISIONED BLOATWARE PACKAGES & CAPABILITIES ]
###############################################################################
#>
Invoke-Safely -Id (++$Step) "Remove provisioned bloatware packages, capabilities and features" {
$activity = "Performing removal of packages..."; Write-Status $activity
$init = Get-Date; $jid = Lock-Random; $task = "Getting ready..."; $pass = 1
$size = ($AppxTBR.Count + $CapsTBR.Count + $CapsTBA.Count + $WOFsTBD.Count + $WOFsTBE.Count + 1) * 100
$update = {
$j = Start-Job $args[1]
while ('Completed' -ne $j.State) {
if ('Failed' -eq $j.State) { throw ($j.Error) }
$working = $j.ChildJobs[0].Progress.PercentComplete | Select-Last
if ("$null" -ne "$working") { $display = "($working% complete)" }
$current = ($pass + $working) / $size; $percent = $current * 100 | Round
$elapsed = ((Get-Date) - $init).TotalSeconds
Write-Progress -Id $jid `
-Activity "Performing removal of packages..." `
-Status "$task ($percent% Complete)" `
-CurrentOperation "$($args[0]) $display" `
-PercentComplete $percent `
-SecondsRemaining (($elapsed / $current) - $elapsed)
}
}
$initializing = {
$current = $pass / $size; $percent = $current * 100 | Round
$elapsed = ((Get-Date) - $init).TotalSeconds
Write-Progress -Id $jid `
-Activity "Performing removal of packages..." `
-Status "$task ($percent% Complete)" `
-CurrentOperation $args[0] `
-PercentComplete $percent `
-SecondsRemaining (($elapsed / $current) - $elapsed)
}
Write-Progress -Id $jid -Activity "Performing removal of packages..." -Status $task -PercentComplete 0
Start-Sleep -Seconds 2
$task = "Removing provisioned packages..."; $initializing.Invoke("Reading packages...")
$availablePkgs = Write-Result { Get-ProvisionedAppxPackage -Path "$ScratchPath" }
if ($AppxTBR) {
$list = $availablePkgs.PackageName
forEach ($appx in $AppxTBR) {
$match = $list | Where-Object { $_ -like "$appx*" } | Select-Last
if (("$null" -ne "$appx") -and ("$null" -ne "$match"))
{
Write-Operation "Remove provisioned Appx package" -Target "$match"
$update.Invoke("Removing $appx", { Remove-ProvisionedAppxPackage -Path "$using:ScratchPath" -PackageName "$using:match" })
}
$pass += 100
}
}
$task = "Removing unnecessary capabilities..."; $initializing.Invoke("Reading capabilities...")
$availableCaps = Write-Result { Get-WindowsCapability -Path "$ScratchPath" }
if ($CapsTBR) {
$list = ($availableCaps | Where-Object { $_.State -eq 'Installed' }).Name
forEach ($cap in $CapsTBR) {
$match = $list | Where-Object { $_ -like "$cap*" } | Select-Last
if (("$null" -ne "$cap") -and ("$null" -ne "$match"))
{
Write-Operation "Remove Windows capability" -Target "$match"
$update.Invoke("Removing $cap", { Remove-WindowsCapability -Path "$using:ScratchPath" -Name "$using:match" })
}
$pass += 100
}
}
if ($CapsTBA) {
$list = ($availableCaps | Where-Object { $_.State -eq 'NotPresent' }).Name
forEach ($cap in $CapsTBA) {
$match = $list | Where-Object { $_ -like "$cap*" } | Select-Last
if (("$null" -ne "$cap") -and ("$null" -ne "$match"))
{
Write-Operation "Add new Windows capability" -Target "$match"
$update.Invoke("Adding $cap", { Add-WindowsCapability -Path "$using:ScratchPath" -Name "$using:match" })
}
$pass += 100
}
}
$task = "Disabling unnecessary features..."; $initializing.Invoke("Reading optional features...")
$availableWOFs = Write-Result { Get-WindowsOptionalFeature -Path "$ScratchPath" }
if ($WOFsTBD) {
$list = ($availableWOFs | Where-Object { $_.State -eq 'Enabled' }).FeatureName
forEach ($wof in $WOFsTBD) {
$match = $list | Where-Object { $_ -eq $wof }
if (("$null" -ne "$wof") -and ("$null" -ne "$match"))
{
Write-Operation "Disable Windows Optional Feature" -Target "$match"
$update.Invoke("Disabling $wof", { Disable-WindowsOptionalFeature -Path "$using:ScratchPath" -FeatureName "$using:match" })
}
$pass += 100
}
}
if ($WOFsTBE) {
$list = ($availableWOFs | Where-Object { $_.State -eq 'Disabled' }).FeatureName
forEach ($wof in $WOFsTBE) {
$match = $list | Where-Object { $_ -eq $wof }
if (("$null" -ne "$wof") -and ("$null" -ne "$match"))
{
Write-Operation "Enable Windows Optional Feature" -Target "$match"
$update.Invoke("Enabling $wof", { Enable-WindowsOptionalFeature -Path "$using:ScratchPath" -FeatureName "$using:match" })
}
$pass += 100
}
}
Write-Progress -Id $jid -Activity $activity -Status "Done." -Completed
Write-Success "Removal complete!"
Unlock-Random $jid
}
Invoke-Safely -Id (++$Step) "Removing microsoft's spyware" {
Write-Status "Removing MSEdge & OneDrive..."; Write-Linebreak 9
$msedge = @(
"$ScratchPath\Program Files (x86)\Microsoft\Edge",
"$ScratchPath\Program Files (x86)\Microsoft\EdgeCore",
"$ScratchPath\Program Files (x86)\Microsoft\EdgeUpdate"
)
if (Test-Paths -Path $msedge -Or) {
Write-Host "Removing Edge..."
Remove-ItemWithProgress -Path $msedge > $null
} else {
Write-Warning "Can't find Microsoft Edge, skipping delete"
}
$webview = "$ScratchPath\Windows\System32\Microsoft-Edge-Webview"
if (Test-Path -Path $webview) {
Write-Host "Removing Edge WebView..."
Remove-ItemWithProgress -Path $webview -AccessRule $FSAR > $null
} else {
Write-Warning "Can't find Microsoft Edge WebView, skipping delete"
}
$webviewSxS = (Get-ChildItem -Path "$ScratchPath\Windows\WinSxS" -Filter "$($arch)_microsoft-edge-webview_31bf3856ad364e35*" -Directory).FullName
if ($webviewSxS) {
Write-Host "Removing System WebView..."
Remove-ItemWithProgress -Path $webviewSxS -AccessRule $FSAR > $null
} else {
Write-Warning "Can't find System WebView, skipping delete"
}
$drive = @(
"$ScratchPath\Windows\System32\OneDriveSetup.exe"
"$ScratchPath\Windows\SysWOW64\OneDriveSetup.exe"
"$ScratchPath\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
)
if (Test-Paths -Path $drive -Or) {
Write-Host "Removing OneDrive..."
Remove-ItemWithProgress -Path $drive -AccessRule $FSAR > $null
} else {
Write-Warning "Can't find Microsoft Edge, skipping delete"
}
Write-Success "Removal complete!"
}
Invoke-Safely -Id (++$Step) "Optimize answerfile" {
Write-Status "Optimizing answerfile..."
Invoke-WebRequest `
-Uri "https://gist.githubusercontent.com/AlphaKR93/73aadf32a18507dda310bf1e7d871178/raw/autounattend.xml?cachebust=&" `
-OutFile "$ScratchPath\Windows\System32\Sysprep\autounattend.xml"
Write-Success "Optimized answerfile!"
}
<#
###############################################################################
[ MAKE THE IMAGE A CORE ]
###############################################################################
#>
Invoke-Safely -When { $MakeCore } -Id (++$Step) "Remove WinRE" {
Write-Status "Removing Windows Recovery Environment..."
Remove-ItemWithProgress -Path "$ScratchPath\Windows\System32\Recovery" -AccessRule $FSAR 1 > $null
Write-Success "Removal Complete!"
}
Invoke-Safely -When { $MakeCore } -Id (++$Step) "Debloat Apperance" {
Write-Status "Removing Theme contents..."
Add-AccessRule -Path "$ScratchPath\Windows\Web" -AccessRule $FSAR -Recurse > $null
Remove-Item -Path "$ScratchPath\Windows\Web" -Force -Recurse > $null
Write-Success "Removal Complete!"
}
Invoke-Safely -When { $MakeCore } -Id (++$Step) "Debloat WinSxS" {
Write-Status "Removing all but essentials from WinSxS..."; Write-Linebreak 9
Add-AccessRule -Path "$ScratchPath\Windows\WinSxS" -AccessRule $FSAR
if (!(Test-Path -Path "$ScratchPath\Windows\WinSxS.bak")) {
Rename-Item -Path "$ScratchPath\Windows\WinSxS" -NewName "$ScratchPath\Windows\WinSxS.bak" -Force
}
$default = @(
"Manifests"
"Catalogs"
"FileMaps"
"SettingsManifests"
"Fusion"
"Temp"
"InstallTemp"
"x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*"
"x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*"
"x86_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*"
"x86_microsoft.windows.common-controls_6595b64144ccf1df_*"
"x86_microsoft.windows.gdiplus_6595b64144ccf1df_*"
"x86_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*"
"x86_microsoft.windows.isolationautomation_6595b64144ccf1df_*"
)
$modern = @(
"ARCH64_microsoft.vc80.crt_1fc8b3b9a1e18e3b_*"
"ARCH64_microsoft.vc90.crt_1fc8b3b9a1e18e3b_*"
"ARCH64_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*"
"ARCH64_microsoft-windows-servicingstack-onecore_31bf3856ad364e35_*"
"ARCH64_microsoft.windows.common-controls_6595b64144ccf1df_*"
"ARCH64_microsoft.windows.gdiplus_6595b64144ccf1df_*"
"ARCH64_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*"
"ARCH64_microsoft.windows.isolationautomation_6595b64144ccf1df_*"
"ARCH64_microsoft-windows-servicingstack_31bf3856ad364e35_*"
"ARCH64_microsoft-windows-servicingstack-inetsrv_31bf3856ad364e35_*"
"ARCH64_microsoft-windows-servicingstack-msg_31bf3856ad364e35_*"
) | ForEach-Object { $_ -replace "ARCH64", $arch }
$component = switch ($arch)
{
'amd64' {@(
"x86_microsoft-windows-s..ngstack-onecorebase_31bf3856ad364e35_*"
"x86_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_*"
"x86_microsoft-windows-servicingstack_31bf3856ad364e35_*"
"x86_microsoft-windows-servicingstack-inetsrv_*"
"x86_microsoft-windows-servicingstack-onecore_*"
"amd64_microsoft-windows-s..stack-inetsrv-extra_31bf3856ad364e35_*"
"amd64_microsoft-windows-s..stack-msg.resources_31bf3856ad364e35_*"
"amd64_microsoft-windows-s..stack-termsrv-extra_31bf3856ad364e35_*"
)}
'arm64' {@(
"arm_microsoft.windows.c..-controls.resources_6595b64144ccf1df_*"
"arm_microsoft.windows.common-controls_6595b64144ccf1df_*"
"arm_microsoft.windows.gdiplus_6595b64144ccf1df_*"
"arm_microsoft.windows.i..utomation.proxystub_6595b64144ccf1df_*"
"arm_microsoft.windows.isolationautomation_6595b64144ccf1df_*"
"arm64_microsoft-windows-servicing-adm_31bf3856ad364e35_*"
"arm64_microsoft-windows-servicingcommon_31bf3856ad364e35_*"
"arm64_microsoft-windows-servicing-onecore-uapi_31bf3856ad364e35_*"
)}
default { Write-Warning "Unsupported architecture: $arch, skipping optimization" }
}
$newSxS = "$ScratchPath\Windows\WinSxS"
New-Item -Path $newSxS -ItemType Directory -Force
Write-Host "Copying base system components..."
Copy-ItemWithProgress `
-Path (($default + $modern + $component) | ForEach-Object { Get-ChildItem -Path "$ScratchPath\Windows\WinSxS.bak" -Filter $_ -Directory -Force }).FullName `
-Destination "$ScratchPath\Windows\WinSxS" `
-Chunk 1 > $null
Write-Host "Removing unnecessary components..."
Remove-ItemWithProgress -Path "$ScratchPath\Windows\WinSxS.bak" -Chunk 0 -AccessRule $FSAR > $null
Write-Success "Removal complete!"
}
<#
###############################################################################
[ APPLY OPTIMIZATIONS TO THE REGISTRY ]
###############################################################################
#>
$takeReg = {
$regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($args[0], [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, [System.Security.AccessControl.RegistryRights]::TakeOwnership)
$regACL = $regKey.GetAccessControl()
$regACL.SetOwner($args[1])
$regKey.SetAccessControl($regACL)
$regKey.Close()
$regKey = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey($args[0], [Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, [System.Security.AccessControl.RegistryRights]::ChangePermissions)
$regACL = $regKey.GetAccessControl()
$regACL.SetAccessRule($regAR)
$regKey.SetAccessControl($regACL)
$regKey.Close()
}
Invoke-Safely -Id (++$Step) "Mount registry hives" {
Write-Status "Mounting registry hives..."
Write-Result { & 'reg' 'load' "HKLM\MICRO11_DEF" "$ScratchPath\Windows\System32\config\default" } > $null
Write-Result { & 'reg' 'load' "HKLM\MICRO11_USR" "$ScratchPath\Users\Default\ntuser.dat" } > $null
Write-Result { & 'reg' 'load' "HKLM\MICRO11_SYS" "$ScratchPath\Windows\System32\config\SYSTEM" } > $null
Write-Result { & 'reg' 'load' "HKLM\MICRO11_SFT" "$ScratchPath\Windows\System32\config\SOFTWARE" } > $null
# Write-Result { & 'reg' 'load' "HKLM\MICRO11_COM" "$ScratchPath\Windows\System32\config\COMPONENTS" } > $null
}
Invoke-Safely -Id (++$Step) "Perform scheduled task cleanup" {
<# $regTask = @(
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{4738DE7A-BCC1-4E2D-B1B0-CADB044BFA81}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{6FAC31FA-4A85-4E64-BFD5-2154FF4594B3}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{FC931F16-B50A-472E-B061-B6F79A71EF59}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{0600DD45-FAF2-4131-A006-0B17509B9F78}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{0671EB05-7D95-4153-A32B-1426B9FE61DB}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{87BF85F4-2CE1-4160-96EA-52F554AA28A2}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{8A9C643C-3D74-4099-B6BD-9C6D170898B1}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{E3176A65-4E44-4ED3-AA73-3283660ACB9C}"
) #>
$targets = @(
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Customer Experience Improvement Program'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Power Efficiency Diagnostics'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Shell\FamilySafetyMonitor'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Shell\FamilySafetyRefresh'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Shell\FamilySafetyUpload'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Application Experience'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\AppID\SmartScreenSpecific'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Autochk'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\NetTrace'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\PI\Sqm-Tasks'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\FileHistory'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\DiskFootprint\Diagnostics'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\CloudExperienceHost'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Windows Error Reporting'
'HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tree\Microsoft\Windows\Management\Provisioning\Logon'
) | Where-Object { Test-Path -Path $_ } | ForEach-Object { Get-ChildItem -Path $_ }
$ids = ($targets | ForEach-Object { Get-ItemProperty -Path ($_ -replace 'HKEY_LOCAL_MACHINE', 'HKLM:') }).Id
$filterName = { (Get-ChildItem -Path $args[0]).Name -replace (($args[0] -replace '\\', '\\') -replace 'HKLM:', 'HKEY_LOCAL_MACHINE'), '' }
$removeThem = { $l = $args; $l[0] | Where-Object { $_ -in $ids } | ForEach-Object {
Write-Operation "Remove Registry Key" -Target $_
try {
Remove-Item -Path "$($l[1])$_" -Force
} catch {
Write-Warning "Cannot remove $_, skipping delete"
}
} }
$clearEvery = {
$takeReg.Invoke(($args[0] -replace 'HKLM:\\', ''), $admins)
$removeThem.Invoke($filterName.Invoke($args[0]), $args[0])
}
Set-Privilege SeTakeOwnershipPrivilege > $null
$clearEvery.Invoke('HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Boot\')
$clearEvery.Invoke('HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Plain\')
$clearEvery.Invoke('HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Logon\')
$clearEvery.Invoke('HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\')
$clearEvery.Invoke('HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Maintenance\')
}
Invoke-Safely -Id (++$Step) "Apply optimizations to registry" {
Write-Status "Optimizing registry..."; Write-Linebreak 10
$init = Get-Date; $jid = Lock-Random; $task = "Getting ready..."
$update = {
$current = (++$pass) / $size; $percent = $current * 100 | Round
$elapsed = ((Get-Date) - $init).TotalSeconds
Write-Progress -Id $jid `
-Activity "Modifying registry keys..." `
-Status "$task ($percent% Complete)" `
-CurrentOperation $args[0] `
-PercentComplete $percent `
-SecondsRemaining (($elapsed / $current) - $elapsed)
}
$initializing = { Write-Progress -Id $jid -Activity "Modifying registry keys..." -Status $task }
$task = "Counting all registry to be modified..."; $initializing.Invoke()
$regRequire = @(
@{Path = "HKLM:\MICRO11_DEF\Control Panel\UnsupportedHardwareNotificationCache"; Name = 'SV1'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_DEF\Control Panel\UnsupportedHardwareNotificationCache"; Name = 'SV2'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\UnsupportedHardwareNotificationCache"; Name = 'SV1'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\UnsupportedHardwareNotificationCache"; Name = 'SV2'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\OOBE"; Name = 'BypassNRO'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\MoSetup"; Name = 'AllowUpgradesWithUnsupportedTPMOrCPU'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassCPUCheck'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassRAMCheck'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassSecureBootCheck'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassStorageCheck'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassTPMCheck'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\Setup\LabConfig"; Name = 'BypassDiskCheck'; Type = 'DWORD'; Data = '1'}
)
$regSponsorAdd = @(
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'ShowSyncProviderNotifications'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\UserProfileEngagement"; Name = 'ScoobeSystemSettingsEnabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SoftLandingEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'ContentDeliveryAllowed'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'FeatureManagementEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SilentInstalledAppsEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SystemPaneSuggestionsEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'PreInstalledAppsEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'PreInstalledAppsEverEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'OEMPreInstalledAppsEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContentEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-338387Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-310093Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-338388Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-338389Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-338393Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-353694Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-353696Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager"; Name = 'SubscribedContent-353698Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\MRT"; Name = 'DontOfferThroughWUAU'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Dsh"; Name = 'AllowNewsAndInterests'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\PushToInstall"; Name = 'DisablePushToInstall'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\Explorer"; Name = 'HideRecommendedSection'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\CloudContent"; Name = 'DisableSoftLanding'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\CloudContent"; Name = 'DisableCloudOptimizedContent'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\CloudContent"; Name = 'DisableWindowsConsumerFeatures'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\CloudContent"; Name = 'DisableWindowsSpotlightFeatures'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\CloudContent"; Name = 'DisableConsumerAccountStateContent'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\PolicyManager\current\device\Start"; Name = 'ConfigureStartPins'; Type = 'STRING'; Data = '{"pinnedList": [{}]}'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\PolicyManager\current\device\Start"; Name = 'ConfigureStartPins_ProviderSet'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\PolicyManager\current\device\Start"; Name = 'ConfigureStartPins_WinningProvider'; Type = 'STRING'; Data = 'B5292708-1619-419B-9923-E5D9F3925E71'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start"; Name = 'ConfigureStartPins'; Type = 'STRING'; Data = '{"pinnedList": [{}]}'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\PolicyManager\providers\B5292708-1619-419B-9923-E5D9F3925E71\default\Device\Start"; Name = 'ConfigureStartPins_LastWrite'; Type = 'DWORD'; Data = '1'}
)
$regSponsorRem = @(
"HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\Subscriptions"
"HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps",
"HKLM:\MICRO11_SFT\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\OutlookUpdate"
"HKLM:\MICRO11_SFT\Microsoft\WindowsUpdate\Orchestrator\UScheduler_Oobe\DevHomeUpdate"
)
$regTelementryAdd = @(
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Input\TIPC"; Name = 'Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\InputPersonalization"; Name = 'RestrictImplicitInkCollection'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\InputPersonalization"; Name = 'RestrictImplicitTextCollection'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\InputPersonalization\TrainedDataStore"; Name = 'HarvestContacts'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy"; Name = 'HasAccepted'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Personalization\Settings"; Name = 'AcceptedPrivacyPolicy'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = 'Enabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Privacy"; Name = 'TailoredExperiencesWithDiagnosticDataEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\Explorer"; Name = 'HideRecentlyAddedApps'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\DataCollection"; Name = 'AllowTelemetry'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\DataCollection"; Name = 'DoNotShowFeedbackNotifications'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\dmwappushservice"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
)
$regChat = @(
@{Path = "HKLM:\MICRO11_USR\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'TaskbarMn'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Communications"; Name = 'ConfigureChatAutoInstall'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\Windows Chat"; Name = 'ChatIcon'; Type = 'DWORD'; Data = '3'}
)
$regBing = @(
@{Path = "HKLM:\MICRO11_USR\Software\Policies\Microsoft\Windows\Explorer"; Name = 'ShowRunAsDifferentUserInStart'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Policies\Microsoft\Windows\Explorer"; Name = 'DisableSearchBoxSuggestions'; Type = 'DWORD'; Data = '1'}
)
$regCopilot = @(
@{Path = "HKLM:\MICRO11_USR\Software\Policies\Microsoft\Windows\WindowsCopilot"; Name = 'TurnOffWindowsCopilot'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'ShowCopilotButton'; Type = 'DWORD'; Data = '0'}
)
$regDriveAdd = @(@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\OneDrive"; Name = 'DisableFileSyncNGSC'; Type = 'DWORD'; Data = '1'})
$regDriveRem = @(@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Run"; Name = "OneDriveSetup"})
$regEdge = @(
"HKLM:\MICRO11_SFT\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge",
"HKLM:\MICRO11_SFT\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Microsoft Edge Update"
)
$regFileSystem = @(
@{Path = "HKLM:\MICRO11_USR\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell"; Name = 'FolderType'; Type = 'STRING'; Data = 'NotSpecified'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\ReserveManager"; Name = 'ShippedWithReserves'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WSearch"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\SysMain"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Control\FileSystem"; Name = 'LongPathsEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Control\FileSystem"; Name = 'NtfsMemoryUsage'; Type = 'DWORD'; Data = '2'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Control\FileSystem"; Name = 'NtfsDisable8dot3NameCreation'; Type = 'DWORD'; Data = '1'}
)
$regWER = @(
@{Path = "HKLM:\MICRO11_USR\Microsoft\Windows\Windows Error Reporting"; Name = 'Disabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Microsoft\Windows\Windows Error Reporting"; Name = 'DontShowUI'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Microsoft\Windows\Windows Error Reporting"; Name = 'OobeCompleted'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Microsoft\Windows\Windows Error Reporting"; Name = 'LoggingDisabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Microsoft\Windows\Windows Error Reporting"; Name = 'DontSendAdditionalData'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\Windows Error Reporting"; Name = 'Disabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\Windows Error Reporting"; Name = 'DontShowUI'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\Windows Error Reporting"; Name = 'OobeCompleted'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\Windows Error Reporting"; Name = 'LoggingDisabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\Windows Error Reporting"; Name = 'DontSendAdditionalData'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\Windows Eroror Reporting"; Name = 'Disabled'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WerSvc"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
)
$regUAC = @(
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Policies\System"; Name = 'EnableLUA'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Policies\System"; Name = 'PromptOnSecureDesktop'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Policies\System"; Name = 'ConsentPromptBehaviorAdmin'; Type = 'DWORD'; Data = '3'}
)
$regAdds = @(
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'JPEGImportQuality'; Type = 'DWORD'; Data = '100'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Narrator\NoRoam"; Name = 'WinEnterLaunchEnabled'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Classes\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}"; Name = 'System.IsPinnedToNameSpaceTree'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\WindowsUpdate\UX\Settings"; Name = 'IsContinuousInnovationOptedIn'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\DriverSearching"; Name = 'SearchOrderConfig'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\RasMan"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\SstpSvc"; Name = 'Start'; Type = 'DWORD'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Session Manager\Memory Management\PrefetchParameters"; Name = 'EnablePrefetcher'; Type = 'DWORD'; Data = '0'}
)
$regAddPath = @(
'HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{645FF040-5081-101B-9F08-00AA002F954E}'
)
$regRems = @(
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83}'
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{F5FB2C77-0E2F-4A16-A381-3E560C68BC83}'
'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{E88865EA-0E1C-4E20-9AA6-EDCD0212C87C}'
'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\DelegateFolders\{E88865EA-0E1C-4E20-9AA6-EDCD0212C87C}'
)
$size = `
$regRequire.Count `
+ $regSponsorAdd.Count `
+ $regSponsorRem.Count `
+ $regTelementryAdd.Count `
+ $regChat.Count `
+ $regBing.Count `
+ $regCopilot.Count `
+ $regDriveAdd.Count `
+ $regDriveRem.Count `
+ $regEdge.Count `
+ $regFileSystem.Count `
+ $regWER.Count `
+ $regUAC.Count `
+ $regAddPath.Count `
+ $regAdds.Count `
+ $regRems.Count + 1
Write-Notify "$size registry items will be modified."
Start-Sleep -Seconds 2
Set-Privilege SeTakeOwnershipPrivilege > $null
$takeReg.Invoke("MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks", $admins)
$takeReg.Invoke("MICRO11_SFT\Microsoft\Windows\CurrentVersion\Communications", $admins)
$addRegPath = {
$update.Invoke("Deleting $_")
Write-Operation "Create Registry Key" -Target $_
New-Item -Path $_ -Force > $null
}
$remRegPath = {
$arg = $_
$update.Invoke("Deleting $arg")
if (Test-Path -Path $arg)
{
Write-Operation "Remove Registry Key" -Target "$arg"
Remove-Item -Path $arg -Force -Recurse > $null
}
else { Write-Warning "Failed to find $_, skipping delete" }
}
$addRegItem = {
$update.Invoke("Creating $($_.Path)\$($_.Name)")
Write-Operation "Create Registry Item" -Target "Item: $($_.Path)\$($_.Name) Value: $($_.Data)"
if (!(Test-Path -Path $_.Path))
{
Write-Operation "Create Registry Key" -Target $_.Path
New-Item -Path $_.Path -Force > $null
}
New-ItemProperty -Path $_.Path -Name $_.Name -PropertyType $_.Type -Value $_.Data -Force > $null
}
$remRegItem = {
$update.Invoke("Deleting $($_.Path)\$($_.Name)")
if (Test-Path -Path "$($_.Path)\$($_.Name)")
{
Write-Operation "Remove Registry Item" -Target "Item: $($_.Path)\$($_.Name)"
Remove-ItemProperty -Path $_.Path -Name $_.Name -Force > $null
}
else { Write-Warning "Failed to find $($_.Path)\$($_.Name), skipping delete" }
}
$task = "Bypassing system requirements..."
$regRequire | ForEach-Object $addRegItem
$task = "Disabling Sponsored Apps..."
$regSponsorAdd | ForEach-Object $addRegItem
$regSponsorRem | ForEach-Object $remRegPath
$task = "Disabling Telementry..."
$regTelementryAdd | ForEach-Object $addRegItem
$task = "Disabling Chat icon..."
$regChat | ForEach-Object $addRegItem
$task = "Disabling bing search..."
$regBing | ForEach-Object $addRegItem
$task = "Disabling Copilot..."
$regCopilot | ForEach-Object $addRegItem
$task = "Disabling OneDrive backup..."
$regDriveAdd | ForEach-Object $addRegItem
$regDriveRem | ForEach-Object $remRegItem
$task = "Removing Edge related keys..."
$regEdge | ForEach-Object $remRegPath
$task = "Tweaking FileSystem related values..."
$regFileSystem | ForEach-Object $addRegItem
$task = "Disabling Windows Error Reporting..."
$regWER | ForEach-Object $addRegItem
$task = "Tweaking User Account Control..."
$regUAC | ForEach-Object $addRegItem
$task = "Finishing..."
$regAddPath | ForEach-Object $addRegPath
$regAdds | ForEach-Object $addRegItem
$regRems | ForEach-Object $remRegPath
Write-Progress -Id $jid -Activity "Modifying registry keys..." -Status "Done." -Completed
Unlock-Random $jid
}
Invoke-Safely -When { $MakeCore } -Id (++$Step) "Apply core-level registry optimizations" {
Write-Status "Applying core-level registry optimizations..."; Write-Linebreak 10
$init = Get-Date; $jid = Lock-Random; $task = "Getting ready..."
$update = {
$current = (++$pass) / $size; $percent = $current * 100 | Round
$elapsed = ((Get-Date) - $init).TotalSeconds
Write-Progress -Id $jid `
-Activity "Modifying registry keys..." `
-Status "$task ($percent% Complete)" `
-CurrentOperation $args[0] `
-PercentComplete $percent `
-SecondsRemaining (($elapsed / $current) - $elapsed)
}
$initializing = { Write-Progress -Id $jid -Activity "Modifying registry keys..." -Status $task }
$task = "Counting all registry to be modified..."; $initializing.Invoke()
$regWinUpdtAdd = @(
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate\AU'; Name = 'UseWUServer'; Type = 'DWORD'; Data = '1'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate\AU'; Name = 'NoAutoUpdate'; Type = 'DWORD'; Data = '1'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate'; Name = 'DoNotConnectToWindowsUpdateInternetLocations'; Type = 'DWORD'; Data = '1'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate'; Name = 'DisableWindowsUpdateAccess'; Type = 'DWORD'; Data = '1'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate'; Name = 'WUServer'; Type = 'STRING'; Data = 'localhost'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate'; Name = 'WUStatusServer'; Type = 'STRING'; Data = 'localhost'}
@{Path = 'HKLM:\MICRO11_SFT\Policies\Microsoft\Windows\WindowsUpdate'; Name = 'UpdateServiceUrlAlternate'; Type = 'STRING'; Data = 'localhost'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\RunOnce"; Name = 'StopWUPostOOBE1'; Type = 'STRING'; Data = 'net stop wuauserv'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\RunOnce"; Name = 'StopWUPostOOBE2'; Type = 'STRING'; Data = 'sc stop wuauserv'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\RunOnce"; Name = 'StopWUPostOOBE3'; Type = 'STRING'; Data = 'sc config wuauserv start= disabled'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\RunOnce"; Name = 'DisbaleWUPostOOBE1'; Type = 'STRING'; Data = 'reg add HKLM\SYSTEM\CurrentControlSet\Services\wuauserv /v Start /t REG_DWORD /d 4 /f'}
@{Path = "HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\RunOnce"; Name = 'DisbaleWUPostOOBE2'; Type = 'STRING'; Data = 'reg add HKLM\SYSTEM\ControlSet001\Services\wuauserv /v Start /t REG_DWORD /d 4 /f'}
@{Path = 'HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\OOBE'; Name = 'DisableOnline'; Type = 'DWORD'; Data = '1'}
@{Path = 'HKLM:\MICRO11_SYS\ControlSet001\Services\wuauserv'; Name = 'Start'; Type = 'DWORD'; Data = '4'}
)
$regWinUpdtRem = @(
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{2540477E-E654-4302-AD44-383BBFFBFF16}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{341B2255-6A6B-442A-AF5A-C610B7DBE12D}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{476E8CFA-78E2-4C51-854E-538F8643B4FD}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{764DDB74-CB08-4E0A-8580-B41F94F2C7BE}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{817CCFDD-4DD0-4102-AC6E-3F5D3B789FB8}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{99CEDA8C-A866-4787-BBD3-6F3C9F61DD5C}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{9B3CDCDA-4197-490B-AA5C-C9F5F42A9D88}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{9CBBFAAE-DB9F-48B4-BAC0-4CFF482A4E01}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{A31197EC-EAEE-4837-8A9C-3A17D358B9EB}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{B4FBEFA9-6F7C-4C74-A891-3774B7BCD072}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{B53BD60A-5823-411C-9C75-AA91DB3C35F8}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{CECDC345-7460-4A15-9D8B-DAC3F9CC5368}"
"HKLM:\MICRO11_SFT\Microsoft\Windows NT\CurrentVersion\Schedule\TaskCache\Tasks\{E0F10DCF-44AD-40E8-9370-FB5DA59F93FB}"
"HKLM:\MICRO11_SYS\ControlSet001\Services\WaaSMedicSVC"
"HKLM:\MICRO11_SYS\ControlSet001\Services\UsoSvc"
)
$regSettings = @(
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'MinAnimate'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'FontSmoothing'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'DragFullWindows'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'AnimationDuration'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'JPEGImportQuality'; Type = 'DWORD'; Data = '0'}
# @{Path = "HKLM:\MICRO11_USR\Control Panel\Desktop"; Name = 'UserPreferencesMask'; Type = 'BINARY'; Data = '90,12,03,80,10,00,00,00'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\DWM"; Name = 'EnableAeroPeek'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\DWM"; Name = 'AlwaysHibernateThumbnails'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; Name = 'EnableTransparency'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'IconsOnly'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'ListviewShadow'; Type = 'DWORD'; Data = '1'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'ListviewAlphaSelect'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'TaskbarAnimations'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; Name = 'UseOLEDTaskbarTransparency'; Type = 'DWORD'; Data = '0'}
@{Path = "HKLM:\MICRO11_USR\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects"; Name = 'VisualFXSettings'; Type = 'DWORD'; Data = '2'}
@{
Path = 'HKLM:\MICRO11_SFT\Microsoft\Windows\CurrentVersion\Policies\Explorer'
Name = 'SettingsPageVisibility'
Type = 'STRING'
Data = "hide:$(@(
'findmydevice'
'recovery'
'troubleshoot'
'windowsdefender'
'speech'
'adddisplaylanguage'
'energyrecommendations'
'quiethours'
'nightlight'
'crossdevice'
'remotedesktop'
'powersleep'
'presence'
'storagerecommendations'
'search'
'privacy'
'mobile-devices'
'deviceusage'
'themes'
'personalization-touchkeyboard'
'lockscreen'
'personalization-lightning'
'colors'
'personalization-background'
'proximity'
'network-dialup'
'network-directaccess'
'gaming-gamebar'
'gaming-gamedvr'
'gaming-gamemode'
'quietmomentsgame'
'family-group'
'easeofaccess-visualeffects'
'devicestyping-hwkbtextsuggestions'
'connecteddevices'
'videoplayback'
'maps'
'sync'
'assignedaccess'
'otherusers'
'emailandaccounts'
'workplace'
) -join ';')"
}
)
$regDefender = @(
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WinDefend"; Name = 'Start'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WdNisSvc"; Name = 'Start'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WdNisDrv"; Name = 'Start'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\WdFilter"; Name = 'Start'; Data = '4'}
@{Path = "HKLM:\MICRO11_SYS\ControlSet001\Services\Sense"; Name = 'Start'; Data = '4'}
)
$size = $regWinUpdtAdd.Count + $regWinUpdtRem.Count + $regSettings.Count + 1
Write-Notify "$size registry items will be modified."
Start-Sleep -Seconds 2
$remRegPath = {
$update.Invoke("Deleting $_")
if (Test-Path -Path $_)
{
Write-Operation "Remove Registry Key" -Target "$_"
Remove-Item -Path $_ -Recurse -Force > $null
}
else { Write-Warning "Failed to find $_, skipping delete" }
}
$addRegItem = {
$update.Invoke("Creating $($_.Path)\$($_.Name)")
if (!(Test-Path -Path $_.Path))
{
Write-Operation "Create Registry Key" -Target $_.Path
New-Item -Path $_.Path -Force > $null
}
Write-Operation "Create Registry Item" -Target "Item: $($_.Path)\$($_.Name) Value: $($_.Data)"
New-ItemProperty -Path $_.Path -Name $_.Name -PropertyType $_.Type -Value $_.Data -Force > $null
}
$modRegItem = {
$update.Invoke("Modifying $($_.Path)\$($_.Name)")
if (Test-Path -Path "$($_.Path)\$($_.Name)")
{
Write-Operation "Modify Registry Item" -Target "Item: $($_.Path)\$($_.Name) Value: $($_.Data)"
Set-ItemProperty -Path $_.Path -Name $_.Name -Value $_.Data > $null
}
else { Write-Warning "Failed to find $($_.Path)\$($_.Name), skipping modify" }
}
$task = "Disabling Windows Update..."
$regWinUpdtAdd | ForEach-Object $addRegItem
$regWinUpdtRem | ForEach-Object $remRegPath
$task = "Disabling Windows Defender..."
$regDefender | ForEach-Object $modRegItem
$task = "Cleaning up Windows settings and default values..."
$regSettings | ForEach-Object $addRegItem
Write-Progress -Id $jid -Activity "Modifying registry keys..." -Status "Done." -Completed
Unlock-Random $jid
}
Invoke-Safely -Id (++$Step) "Unmount registry hives" {
Write-Status "Unmounting registry..."
[gc]::collect()
Start-Sleep -Seconds 2
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_DEF" } > $null
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_USR" } > $null
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SYS" } > $null
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SFT" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_DRV" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_COM" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SCM" } > $null
}
<#
###############################################################################
[ APPLY CHANGES AND OPTIMIZATION TO THE INSTALLATION IMAGE ]
###############################################################################
#>
Invoke-Safely -Id (++$Step) "Apply changes and optimization to the image" {
Write-Status "Successfully optimized setup image." -Success
Write-Notify "If you want to apply additional changes, apply, then press exit the shell."
if (!$y) { Start-Process powershell -NoNewWindow -Wait }
Write-Status "Saving modified image..."
Write-Linebreak 6
Write-Host "Cleaning up image..."
Repair-WindowsImage -Path "$ScratchPath" -StartComponentCleanup -ResetBase > $null
Write-Host "Unmounting image... This might take a while"
Dismount-WindowsImage -Path "$ScratchPath" -Save > $null
Write-Status "Exporting image... This might take a while"
Invoke-Immediately 'DISM.exe' `
'/English' `
'/Export-Image' `
"/SourceImageFile:$source\sources\install.wim" `
"/SourceIndex:$Index" `
"/DestinationImageFile:$source\sources\install.esd" `
'/compress:recovery'
Write-Status "Deleting original image file..."
Remove-Item -Path "$source\sources\install.wim" > $null
Write-Success "Successfully generated image file."
}
<#
###############################################################################
[ OPTIMIZE BOOT IMAGE ]
###############################################################################
#>
Invoke-Safely -When { !$SkipBoot } -Id (++$Step) "Mount boot image" {
Write-Status "Mounting boot (Setup) image..."
Add-AccessRule -Path "$source\sources\boot.wim" -AccessRule $FSAR > $null
Set-ItemProperty -Path "$source\sources\boot.wim" -Name IsReadOnly -Value $false > $null
Mount-WindowsImage -ImagePath "$source\sources\boot.wim" -Index 2 -Path "$ScratchPath" > $null
Write-Success "Mount complete."
}
Invoke-Safely -When { !$SkipBoot } -Id (++$Step) "Bypass setup system requirements" {
Write-Status "Bypassing setup system requirements..."
Write-Result { & 'reg' 'load' "HKLM\MICRO11_DEF" "$ScratchPath\Windows\System32\config\default" } > $null
Write-Result { & 'reg' 'load' "HKLM\MICRO11_USR" "$ScratchPath\Users\Default\ntuser.dat" } > $null
Write-Result { & 'reg' 'load' "HKLM\MICRO11_SYS" "$ScratchPath\Windows\System32\config\SYSTEM" } > $null
# Write-Result { & 'reg' 'load' "HKLM\MICRO11_SFT" "$ScratchPath\Windows\System32\config\SOFTWARE" } > $null
# Write-Information { & 'reg' 'load' "HKLM\MICRO11_COM" "$ScratchPath\Windows\System32\config\COMPONENTS" } > $null
New-Item "HKLM:\MICRO11_DEF\Control Panel\UnsupportedHardwareNotificationCache" -Force > $null
New-Item "HKLM:\MICRO11_USR\Control Panel\UnsupportedHardwareNotificationCache" -Force > $null
New-Item "HKLM:\MICRO11_SYS\Setup\LabConfig" -Force > $null
New-Item "HKLM:\MICRO11_SYS\Setup\MoSetup" -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_DEF\Control Panel\UnsupportedHardwareNotificationCache" -Name 'SV1' -PropertyType 'DWORD' -Value '0' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_DEF\Control Panel\UnsupportedHardwareNotificationCache" -Name 'SV2' -PropertyType 'DWORD' -Value '0' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_USR\Control Panel\UnsupportedHardwareNotificationCache" -Name 'SV1' -PropertyType 'DWORD' -Value '0' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_USR\Control Panel\UnsupportedHardwareNotificationCache" -Name 'SV2' -PropertyType 'DWORD' -Value '0' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassCPUCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassRAMCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassSecureBootCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassStorageCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassTPMCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\LabConfig" -Name 'BypassDiskCheck' -PropertyType 'DWORD' -Value '1' -Force > $null
New-ItemProperty -Path "HKLM:\MICRO11_SYS\Setup\MoSetup" -Name 'AllowUpgradesWithUnsupportedTPMOrCPU' -PropertyType 'DWORD' -Value '1' -Force > $null
[gc]::collect()
Start-Sleep -Seconds 2
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_DEF" } > $null
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_USR" } > $null
Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SYS" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SFT" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_DRV" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_COM" } > $null
# Write-Result { & 'reg' 'unload' "HKLM\MICRO11_SCM" } > $null
Write-Success "Bypass complete."
Start-Sleep -Seconds 2
}
Invoke-Safely -When { !$SkipBoot } -Id (++$Step) "Apply changes to the boot image" {
Write-Status "Unmounting image... This might take a while"
Dismount-WindowsImage -Path "$ScratchPath" -Save > $null
Write-Success "The micro11 image is now completed."
}
<#
###############################################################################
[ GENERATE MICRO11 INSTALLATION MEDIA ISO ]
###############################################################################
#>
Invoke-Safely -Id (++$Step) "Optimize answerfile" {
Write-Status "Optimizing answerfile..."
Invoke-WebRequest `
-Uri "https://gist.githubusercontent.com/AlphaKR93/73aadf32a18507dda310bf1e7d871178/raw/autounattend.xml?cachebust=&" `
-OutFile "$source\autounattend.xml"
Write-Success "Optimized answerfile!"
}
Invoke-Safely -When { !$SkipISO } -Id (++$Step) "Check the availability of OSCDIMG" {
Write-Status "Checking availability of OSCDIMG..."
$asCommand = Get-Command -Name "oscdimg" -ErrorAction SilentlyContinue
if ($null -ne $asCommand) {
Write-Success "Use the system OSCDIMG."
$global:OSCDIMG = $asCommand.Source
return
}
$PROGRAMFILES = Get-Item -Path "ENV:\ProgramFiles(x86)"
$asADK = "$PROGRAMFILES\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\$arch\Oscdimg\oscdimg.exe"
if (Test-Path -Path $asADK) {
Write-Success "Windows ADK detected, using the OSCDIMG built into the ADK."
$global:OSCDIMG = $asADK
return
}
$asLocal = "$WorkPath\oscdimg.exe"
if (Test-Path -Path $asLocal) {
Write-Success "Use a locally installed OSCDIMG."
$global:OSCDIMG = $asLocal
return
}
Write-Warning "No installed OSCDIMG found. Use Stock OSCDIMG."
}
Invoke-Safely -When { !$SkipISO -and ($null -eq $OSCDIMG) } -Id (++$Step) "Install OSCDIMG" {
Write-Status "Installing OSCDIMG..."
$LocalPath = "$WorkPath\oscdimg.exe"
Invoke-WebRequest `
-Uri "https://msdl.microsoft.com/download/symbols/oscdimg.exe/3D44737265000/oscdimg.exe" `
-OutFile $LocalPath
if (Test-Path -Path $LocalPath) {
Write-Success "OSCDIMG installed successfully."
$global:OSCDIMG = $LocalPath
return
}
Write-Error "Failed to download OSCDIMG."
}
Invoke-Safely -When { !$SkipISO } -Id (++$Step) "Create micro11 installation media ISO" {
Write-Status "Creating installation media ISO..."
Invoke-Immediately "$OSCDIMG" `
'-m' `
'-o' `
'-u2' `
'-udfver102' `
"-bootdata:2#p0,e,b$source\boot\etfsboot.com#pEF,e,b$source\efi\microsoft\boot\efisys.bin" `
"$source" `
"$WorkPath\micro11.iso"
Write-Success "Created ISO image!"
}
Invoke-Safely "Perform cleanup" {
Write-Status "Successfully generated $BRANDING!" -Success
if (!$y) { Read-Host "Press Enter to exit the script" }
Write-Status "Performing cleanup..."
Remove-ItemWithProgress -Path "$source", "$ScratchPath" > $null
}
Stop-Transcript
Clear-Host
exit

Nothing to see here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment