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 (
    [string]$pathtowim,
    [bool]$selectapps,
    [string]$index="1"
    )

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

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

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
    "Microsoft.3DBuilder"
    "Microsoft.Appconnector"
    "Microsoft.BingFinance"
    "Microsoft.BingNews"
    "Microsoft.BingSports"
    "Microsoft.BingWeather"
    #"Microsoft.FreshPaint"
    "Microsoft.Getstarted"
    "Microsoft.MicrosoftOfficeHub"
    "Microsoft.MicrosoftSolitaireCollection"
    #"Microsoft.MicrosoftStickyNotes"
    "Microsoft.Office.OneNote"
    #"Microsoft.OneConnect"
    "Microsoft.People"
    "Microsoft.SkypeApp"
    #"Microsoft.Windows.Photos"
    #"Microsoft.WindowsAlarms"
    #"Microsoft.WindowsCalculator"
    #"Microsoft.WindowsCamera"
    #"Microsoft.WindowsMaps"
    "Microsoft.WindowsPhone"
    #"Microsoft.WindowsSoundRecorder"
    #"Microsoft.WindowsStore"
    "Microsoft.XboxApp"
    "Microsoft.ZuneMusic"
    "Microsoft.ZuneVideo"
    "microsoft.windowscommunicationsapps"
    "Microsoft.MinecraftUWP"
    "Microsoft.MicrosoftPowerBIForWindows"
    #"Microsoft.NetworkSpeedTest"
    
    # Threshold 2 apps
    "Microsoft.CommsPhone"
    #"Microsoft.ConnectivityStore"
    "Microsoft.Messaging"
    "Microsoft.Office.Sway"
    "Microsoft.OneConnect"
    "Microsoft.WindowsFeedbackHub"

    #Redstone apps
    "Microsoft.BingFoodAndDrink"
    "Microsoft.BingTravel"
    "Microsoft.BingHealthAndFitness"
    "Microsoft.WindowsReadingList"

    # non-Microsoft
    "9E2F88E3.Twitter"
    "PandoraMediaInc.29680B314EFC2"
    "Flipboard.Flipboard"
    "ShazamEntertainmentLtd.Shazam"
    "king.com.CandyCrushSaga"
    "king.com.CandyCrushSodaSaga"
    "king.com.*"
    "ClearChannelRadioDigital.iHeartRadio"
    "4DF9E0F8.Netflix"
    "6Wunderkinder.Wunderlist"
    "Drawboard.DrawboardPDF"
    "2FE3CB00.PicsArt-PhotoStudio"
    "D52A8D61.FarmVille2CountryEscape"
    "TuneIn.TuneInRadio"
    "GAMELOFTSA.Asphalt8Airborne"
    "TheNewYorkTimes.NYTCrossword"
    "DB6EA5DB.CyberLinkMediaSuiteEssentials"
    "Facebook.Facebook"
    "flaregamesGmbH.RoyalRevolt2"
    "Playtika.CaesarsSlotsFreeCasino"
    "A278AB0D.MarchofEmpires"
    "KeeperSecurityInc.Keeper"
    "ThumbmunkeysLtd.PhototasticCollage"
    "XINGAG.XING"
    "89006A2E.AutodeskSketchBook"
    "D5EA27B7.Duolingo-LearnLanguagesforFree"
    "46928bounde.EclipseManager"
    "ActiproSoftwareLLC.562882FEEB491" # next one is for the Code Writer from Actipro Software LLC

    # apps which cannot be removed using Remove-AppxPackage
    #"Microsoft.BioEnrollment"
    #"Microsoft.MicrosoftEdge"
    #"Microsoft.Windows.Cortana"
    #"Microsoft.WindowsFeedback"
    #"Microsoft.XboxGameCallableUI"
    #"Microsoft.XboxIdentityProvider"
    #"Windows.ContactSupport"
)

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

sn3rvg1i

Leave a Reply

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