Remove Windows10 bloatware from WIM using PowerShell

The logic behind writing this script is to remove unwanted built-in apps from Windows 10 1909 Operating System. This script can be used to remove Windows 10 built-In Apps in OS as well as in Task Sequence Deployment.

You can mention the list of applications to remove from the OS, based on your business requirement.

<#

    .SYNOPSIS

    Removing Windows 10 1909 Built-In Apps.

    .DESCRIPTION

   

    .NOTES

    =============================================================================================================================================

    Created with:     Windows PowerShell ISE

    Created on:       Wednesday, October 6, 2021 5:41:31 PM

    Created by:       Dashrath Chate

 

# Main Routine

#---------------------------------------------------------------------------------------------------------------

 

# Get log path. Will log to Task Sequence log folder if the script is running in a Task Sequence

# Otherwise log to \windows\temp

 

try

 

{

 

    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment

 

    $logPath = $tsenv.Value("LogPath")

 

}

 

catch

 

{

 

    Write-Host "This script is not running in a task sequence"

 

    $logPath = $env:windir + "\temp"

 

}

 

$logFile = "$logPath\$($myInvocation.MyCommand).log"

 

# Start logging

 

Start-Transcript $logFile

 

Write-Host "Logging to $logFile"

 

# List of Applications that will be removed

 

$AppsList = "Microsoft.XboxGamingOverlay","Microsoft.XboxGameOverlay","Microsoft.XboxSpeechToTextOverlay","Microsoft.Xbox.TCUI","Microsoft.XboxApp","Microsoft.XboxIdentityProvider","microsoft.windowscommunicationsapps","Microsoft.BingWeather","Microsoft.WindowsFeedbackHub","Microsoft.GetHelp","Microsoft.MixedReality.Portal","Microsoft.SkypeApp","Microsoft.Messaging","Microsoft.ZuneMusic","Microsoft.ZuneVideo","Microsoft.People","Microsoft.Office.OneNote","Microsoft.MicrosoftOfficeHub","Microsoft.OneConnect"

 

ForEach ($App in $AppsList){

 

    $Packages = Get-AppxPackage | Where-Object {$_.Name -eq $App}

 

    if ($Packages -ne $null)

 

    {

 

          Write-Host "Removing Appx Package: $App"

 

          foreach ($Package in $Packages)

 

          {

 

          Remove-AppxPackage -package $Package.PackageFullName

 

          }

    }

    else

    {

          Write-Host "Unable to find package: $App"

    }

    $ProvisionedPackage = Get-AppxProvisionedPackage -online | Where-Object {$_.displayName -eq $App}

    if ($ProvisionedPackage -ne $null)

    {

          Write-Host "Removing Appx Provisioned Package: $App"

          remove-AppxProvisionedPackage -online -packagename $ProvisionedPackage.PackageName

    }

    else

    {

          Write-Host "Unable to find provisioned package: $App"

    }

}

# Uninstalls app which cannot be removed using Get-AppxProvisionedPackage and Remove-AppxPackage

#Start-Process -FilePath Dism.exe -ArgumentList "/online /remove-package /PackageName:Microsoft-Windows-ContactSupport-Package~31bf3856ad364e35~amd64~~10.0.14393.0" -NoNewWindow -Passthru -Wait -ErrorAction silentlycontinue

Start-Process -FilePath Dism.exe -ArgumentList "/online /remove-provisionedappxpackage /packagename:Microsoft.Xbox.TCUI_1.23.28002.0_neutral_~_8wekyb3d8bbwe" -NoNewWindow -Passthru -Wait -ErrorAction silentlycontinue

Start-Process -FilePath Dism.exe -ArgumentList "/online /remove-provisionedappxpackage /packagename:Microsoft.XboxGameOverlay_1.32.17005.0_neutral_~_8wekyb3d8bbwe" -NoNewWindow -Passthru -Wait -ErrorAction silentlycontinue

Start-Process -FilePath Dism.exe -ArgumentList "/online /remove-provisionedappxpackage /packagename:Microsoft.XboxGamingOverlay_2.26.14003.0_neutral_~_8wekyb3d8bbwe" -NoNewWindow -Passthru -Wait -ErrorAction silentlycontinue

Start-Process -FilePath Dism.exe -ArgumentList "/online /remove-provisionedappxpackage /packagename:Microsoft.XboxSpeechToTextOverlay_1.17.29001.0_neutral_~_8wekyb3d8bbwe" -NoNewWindow -Passthru -Wait -ErrorAction silentlycontinue

# Stop logging

Stop-Transcript

No comments:

Post a Comment

Leave your valuable words here for improve better.