Prepping Windows 10

Prepping Windows 10

If you want to prep a Windows 10 image to remove the applications you don’t want, there are two ways. You can either do it by stripping the ISO and removing them before installing, or install Windows 10 and then run a scrip to remove them. Here’s what I did to our image.

1. Mount the ISO
2. Copy out the “install.wim” file located in sources to “C:\Temp\10”
3. Copy the script below, paste it into a powershell file and save in the same location as the install.wim

param (

$Host.UI.RawUI.BackgroundColor = "Black"; Clear-Host
$startdate = (Get-Date).ToString()

function CreateTempDirectory {
   $tmpDir = [System.IO.Path]::GetTempPath()
   $tmpDir = [System.IO.Path]::Combine($tmpDir, [System.IO.Path]::GetRandomFileName())
   [System.IO.Directory]::CreateDirectory($tmpDir) | Out-Null

try {
    $pathworkfolder = CreateTempDirectory
    Write-Host "Start:" $startdate -ForegroundColor White
    Write-Host "Create temporary directory..." -ForegroundColor Green
    Write-Host "Temporary directory:" $pathworkfolder -ForegroundColor Green

catch [Exception] {
    Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break

try {
    Write-Host "Mounting Windows-Image..." $pathtowim -ForegroundColor Green
    Write-Host "Please wait..." -ForegroundColor White
    Mount-WindowsImage -Path $pathworkfolder -ImagePath $pathtowim -Index $index | Out-Null

catch [Exception] {
    Write-Host "Mounting Windows-Image failed..." -ForegroundColor Red;
    Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break

try {
    Write-Host "Remove the following Built-in apps:" -ForegroundColor Green 
    $apps = Get-AppxProvisionedPackage -Path $pathworkfolder | ForEach-Object {

    if($selectapps -eq $true) {
    $call = read-host "Do you really want to delete the following App:" $_.DisplayName "(Y/N)"
    if($call -eq "y") {
    Write-Host "Delete:" $_.DisplayName -ForegroundColor Green
    Remove-AppxProvisionedPackage -Path $pathworkfolder -PackageName $_.PackageName
    $call = ""

    else {
    Write-Host "Skipped:" $_.DisplayName -ForegroundColor yellow
    else {
    Write-Host "Delete:" $_.DisplayName -ForegroundColor Green
    Remove-AppxProvisionedPackage -Path $pathworkfolder -PackageName $_.PackageName 
    $call = ""

catch [Exception] {
    Write-Host "Removing Built-in apps failed..." -ForegroundColor Red;
    Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break

try {
    Write-Host "Dismount-WindowsImage..." -ForegroundColor Green
    Write-Host "Please wait..." -ForegroundColor White
    Dismount-WindowsImage -Path $pathworkfolder  -Save -CheckIntegrity | Out-Null
    Write-Host "Remove temporary directory..." -ForegroundColor Green
    Remove-Item $pathworkfolder -Recurse -Force | Out-Null
    Write-Host "Complete:" (Get-Date).ToString() -ForegroundColor White

catch [Exception] {
    Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break

4. Open an elevated PowerShell prompt, navigate to c:\temp\10 and type the following: .\[b]Filename[/b].ps1 -pathtowim c:\temp\10\install.wim -select $true -index [b][u]”Change this to the index number of the OS you are editing”[/u][/b]
5. Use the prompts to remove whatever you want
6. Once its finished and the changes have been committed, put the install.wim back into the ISO using your favourite method
7. Remove ANY network connections from the machine or disable the NIC in the VM
8. Boot from the ISO and Install Windows 10
9. On first login, disable customer experiences by opening the local group policy editor and go here: “Computer Configuration > Administrative Templates > Windows Components > Cloud Content” and enabling “Turn off Microsoft consumer experience” this will stop things like Candy Crush and the other built-in rubbish NOBODY wants. You can now enable your network connection
10. Run Windows and Store updates
11. Your start menu wont look fantastic as there will be loads of blank tiles but once they have been removed, the won’t come back

If you want to remove the packages after Windows is installed, follow steps 7 to 10 and the run the below script as an admin.

# This script removes unwanted Apps that come with Windows. If you  do not want
# to remove certain Apps comment out the corresponding lines below.

Import-Module -DisableNameChecking $PSScriptRoot\..\lib\take-own.psm1
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\force-mkdir.psm1

Write-Output "Elevating privileges for this process"
do {} until (Elevate-Privileges SeTakeOwnershipPrivilege)

Write-Output "Uninstalling default apps"
$apps = @(
    # default Windows 10 apps
    # Threshold 2 apps

    #Redstone apps

    # non-Microsoft
    "ActiproSoftwareLLC.562882FEEB491" # next one is for the Code Writer from Actipro Software LLC

    # apps which cannot be removed using Remove-AppxPackage

foreach ($app in $apps) {
    Write-Output "Trying to remove $app"

    Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage -AllUsers

    Get-AppXProvisionedPackage -Online |
        Where-Object DisplayName -EQ $app |
        Remove-AppxProvisionedPackage -Online

# Prevents "Suggested Applications" returning
force-mkdir "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content"
Set-ItemProperty "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Cloud Content" "DisableWindowsConsumerFeatures" 1


Leave a Reply

Your email address will not be published. Required fields are marked *