#Script to remove modern-ui applications from Windows 8.1 Build & Capture during sysprep process #Made by Kieren Anderson #Purpose: Remove built in apps that are not compatible during sysprep process #Pre-Reqs: Windows 8.1

#—————————————————————————————————————

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.Media.PlayReadyClient.2_2.11.2154.0_x64__8wekyb3d8bbwe”

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"

}

}

Stop logging

Stop-Transcript