<#
.SYNOPSIS
Removing Built-in apps from Windows 10
.DESCRIPTION
Removing Built-in apps from Windows 10
.PARAMETER
PathtoWim - Full path to .wim file.
selectapps - activates the selection function
index - allows the selection of an index. Default value is 1.
.EXAMPLE
.\removeapps.ps1 -pathtowim c:\10\install.wim
.\removeapps.ps1 -pathtowim c:\10\install.wim -selectapps $true
.\removeapps.ps1 -pathtowim c:\10\install.wim -selectapps $true -index 2
.NOTES
Script name: removeapps.ps1
Version: 1.3
Author: Django x2
Contact: Dev
DateCreated: 2018-07-22
LastUpdate: 2019-01-20
#>
param (
[string]$pathtowim,
[string]$selectapps,
[string]$index="1"
)
$Host.UI.RawUI.BackgroundColor = "DarkBlue"; Clear-Host
$startdate = (Get-Date).ToString()
$ProgressPreference=’SilentlyContinue’
$WhiteListedApps = @(
"Microsoft.BingWeather",
"Microsoft.DesktopAppInstaller",
"Microsoft.StorePurchaseApp",
"Microsoft.Office.OneNote",
"Microsoft.WindowsCalculator",
"Microsoft.WindowsStore",
"Microsoft.MicrosoftStickyNotes",
"Microsoft.HEIFImageExtension",
"Microsoft.ScreenSketch",
"Microsoft.VP9VideoExtensions",
"Microsoft.Windows.Photos",
"Microsoft.WebMediaExtensions",
"Microsoft.WebpImageExtension",
"Microsoft.WindowsMaps",
"Microsoft.WindowsSoundRecorder"
"Microsoft.MSPaint"
)
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
}
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
}