Skip to content

Instantly share code, notes, and snippets.

@jNizM
Last active March 28, 2018 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jNizM/036a79afb0372edf32bdf2776279ad3f to your computer and use it in GitHub Desktop.
Save jNizM/036a79afb0372edf32bdf2776279ad3f to your computer and use it in GitHub Desktop.
[UNFINISHED] Create a windows 10 iso without crappy and useless windows appx packages
<#
.WINDOWS 10 ENTERPRISE N
todo todo todo
.UNZIP ISO
->
.RUN .PS1 SCRIPT
.CREATE ISO
ImgBurn (http://www.imgburn.com)
-> Advanced
-> Bootable Disc
-> Make Image Bootable: Check
-> Boot Image: etfsboot.com
-> Sectors to load: 8
.CREATE BOOTABLE USB (FOR SECURE BOOT)
Rufus (https://rufus.akeo.ie)
-> GPT UEFI
-> FAT32
-> 16 Kb
#>
### GLOBAL SETTINGS
$Host.UI.RawUI.BackgroundColor = "Black"; Clear-Host
$ImagePath = "D:\windows\image\install.wim"
$MountPath = "D:\windows\mount"
$FinalPath = "D:\windows\final\install.wim"
$Index = "4"
$WhiteList = @(
### 1607
# "Microsoft.WindowsAlarms", # Alarms & Clock
# "Microsoft.DesktopAppInstaller", # App Installer
"Microsoft.WindowsCalculator", # Calculator
# "Microsoft.WindowsCamera", # Camera
# "Microsoft.WindowsFeedbackHub", # Feedback Hub
# "Microsoft.MicrosoftOfficeHub", # Get Office/My Office
# "Microsoft.SkypeApp", # Get Skype/Skype (preview)/Skype
# "Microsoft.Getstarted", # Get Started/Tips
# "Microsoft.ZuneMusic", # Groove
# "microsoft.windowscommunicationsapps", # Mail and Calendar
# "Microsoft.WindowsMaps", # Maps
# "Microsoft.Messaging", # Messaging
# "Microsoft.ZuneVideo", # Movies & TV
# "Microsoft.BingNews", # News
# "Microsoft.Office.OneNote", # OneNote
# "Microsoft.People", # People
"Microsoft.Windows.Photos", # Photos
# "Microsoft.MicrosoftSolitaireCollection", # Solitaire
# "Microsoft.MicrosoftStickyNotes", # Sticky Notes
"Microsoft.WindowsStore", # Store
# "Microsoft.WindowsSoundRecorder", # Voice Recorder
# "Microsoft.BingWeather", # Weather
# "Microsoft.XboxApp", # Xbox
# "Microsoft.OneConnect", # Xbox
# "Microsoft.StorePurchaseApp", # Xbox
# "Microsoft.XboxIdentityProvider", # Xbox
### 1703
# "Microsoft.3DBuilder", # 3D Builder
# "Microsoft.Microsoft3DViewer", # Microsoft 3D Viewer
"Microsoft.MSPaint", # Paint 3D
# "Microsoft.Wallet", # Wallet
# "Microsoft.XboxGameOverlay", # Xbox
# "Microsoft.XboxSpeechToTextOverlay", # Xbox
### 1709
# "Microsoft.GetHelp", # Get Help
# "Microsoft.Print3D", # Print 3D
# "Microsoft.Office.Sway", # Sway
"Microsoft.Xbox.TCUI", # Xbox
)
### START
Write-Host "Job Start: " (Get-Date).ToString() -ForegroundColor White
### MOUNT AN IMAGE
try
{
Write-Host "Mounting Windows-Image..." -ForegroundColor Green
DISM /Mount-Image /ImageFile:$ImagePath /Index:$Index /MountDir:$MountPath
}
catch [Exception]
{
Write-Host "Error: " $_.Exception.Message -ForegroundColor Red; break
}
### REMOVE UNWANTED APPX PACKAGES (WHITELIST)
Write-Host "Remove unwanted appx packages..." -ForegroundColor Green
$PackageFullName = Get-AppxProvisionedPackage -Path $MountPath | ForEach-Object
{
if ($_.DisplayName -in $WhiteList)
{
Write-Host "Skipped: " $_.DisplayName -ForegroundColor Yellow
}
else
{
Write-Host "Delete: " $_.DisplayName -ForegroundColor Green
Remove-AppxProvisionedPackage -Path $MountPath -PackageName $_.PackageName
}
}
### DISABLE SPECIFIED FEATURES
try
{
Write-Host "Disable specific windows features..." -ForegroundColor Green
DISM /Image:$MountPath /Disable-Feature /FeatureName:WorkFolders-Client
DISM /Image:$MountPath /Disable-Feature /FeatureName:Printing-XPSServices-Features
DISM /Image:$MountPath /Disable-Feature /FeatureName:Xps-Foundation-Xps-Viewer
DISM /Image:$MountPath /Disable-Feature /FeatureName:FaxServicesClientPackage
DISM /Image:$MountPath /Disable-Feature /FeatureName:Printing-Foundation-InternetPrinting-Client
DISM /Image:$MountPath /Disable-Feature /FeatureName:Microsoft-Windows-Printing-XPSServices-Package
}
catch [Exception]
{
Write-Host "Error: " $_.Exception.Message -ForegroundColor Red; break
}
### UNMOUNT AND COMMIT THE CHANGES
try
{
Write-Host "Unmount and commit changes..." -ForegroundColor Green
DISM /Unmount-Image /MountDir:$MountPath /Commit
}
catch [Exception]
{
Write-Host "Error: " $_.Exception.Message -ForegroundColor Red; break
}
### EXPORT AND COMPRESS THE IMAGE
try
{
Write-Host "Export and compress the image..." -ForegroundColor Green
DISM /Export-Image /SourceImageFile:$ImagePath /SourceIndex:$Index /DestinationImageFile:$FinalPath /Compress:max /CheckIntegrity
}
catch [Exception]
{
Write-Host "Error: " $_.Exception.Message -ForegroundColor Red; break
}
### FINISH
Write-Host "Job End: " (Get-Date).ToString() -ForegroundColor White
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment