Created
August 25, 2017 17:08
-
-
Save pauldalewilliams/608ea7bcebae1a48b894e1c453ab1010 to your computer and use it in GitHub Desktop.
Cleanup Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
This script configures Windows 10 with minimal configuration for VDI. | |
.DESCRIPTION | |
This script configures Windows 10 with minimal configuration for VDI. | |
// ============== | |
// General Advice | |
// ============== | |
Before finalizing the image perform the following tasks: | |
- Ensure no unwanted startup files by using autoruns.exe from SysInternals | |
- Run the Disk Cleanup tool as administrator and delete all temporary files and system restore points | |
- Run disk defrag and consolidate free space: defrag c: /v /x | |
- Reboot the machine 6 times and wait 120 seconds after logging on before performing the next reboot (boot prefetch training) | |
- Run disk defrag and optimize boot files: defrag c: /v /b | |
- If using a dynamic virtual disk, use the vendor's utilities to perform a "shrink" operation | |
// ************* | |
// * CAUTION * | |
// ************* | |
THIS SCRIPT MAKES CONSIDERABLE CHANGES TO THE DEFAULT CONFIGURATION OF WINDOWS. | |
Please review this script THOROUGHLY before applying to your virtual machine, and disable changes below as necessary to suit your current | |
environment. | |
This script is provided AS-IS - usage of this source assumes that you are at the very least familiar with PowerShell, and the tools used | |
to create and debug this script. | |
In other words, if you break it, you get to keep the pieces. | |
.PARAMETER NoWarn | |
Removes the warning prompts at the beginning and end of the script - do this only when you're sure everything works properly! | |
.EXAMPLE | |
.\ConfigWin10asVDI.ps1 -NoWarn $true | |
.NOTES | |
Author: Carl Luberti | |
Last Update: 21st April 2016 | |
Version: 1.0.4 | |
.LOG | |
1.0.1 - modified sc command to sc.exe to prevent PS from invoking set-content | |
1.0.2 - modified Universal Application section to avoid issues with CopyProfile, updated onedrive removal, updated for TH2 | |
1.0.3 - modified Universal Application section to disable "Consumer Experience" features, modified scheduled tasks to align with 1511 and further version supportability | |
1.0.4 - fixed duplicates / issues in service config | |
#> | |
# Parse Params: | |
[CmdletBinding()] | |
Param( | |
[Parameter( | |
Position=0, | |
Mandatory=$False, | |
HelpMessage="True or False, do you want to see the warning prompts" | |
)] | |
[bool] $NoWarn = $True | |
) | |
# Throw caution (to the wind?) - show if NoWarn param is not passed, or passed as $false: | |
If ($NoWarn -eq $False) | |
{ | |
Write-Host "THIS SCRIPT MAKES CONSIDERABLE CHANGES TO THE DEFAULT CONFIGURATION OF WINDOWS." -ForegroundColor Yellow | |
Write-Host "" | |
Write-Host "Please review this script THOROUGHLY before applying to your virtual machine, and disable changes below as necessary to suit your current environment." -ForegroundColor Yellow | |
Write-Host "" | |
Write-Host "This script is provided AS-IS - usage of this source assumes that you are at the very least familiar with PowerShell, and the tools used to create and debug this script." -ForegroundColor Yellow | |
Write-Host "" | |
Write-Host "" | |
Write-Host "In other words, if you break it, you get to keep the pieces." -ForegroundColor Magenta | |
Write-Host "" | |
Write-Host "" | |
} | |
$ProgressPreference = "SilentlyContinue" | |
$ErrorActionPreference = "SilentlyContinue" | |
# Configure Constants: | |
$BranchCache = "False" | |
$Cortana = "False" | |
$DiagService = "False" | |
$EAPService = "False" | |
$EFS = "False" | |
$FileHistoryService = "False" | |
$iSCSI = "False" | |
$MachPass = "True" | |
$MSSignInService = "True" | |
$OneDrive = "True" | |
$PeerCache = "False" | |
$Search = "True" | |
$SMB1 = "False" | |
$SMBPerf = "False" | |
$Themes = "True" | |
$Touch = "False" | |
$StartApps = "False" | |
$AllStartApps = "False" | |
# Set up additional registry drives: | |
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null | |
New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null | |
# Get list of Provisioned Start Screen Apps | |
$Apps = Get-ProvisionedAppxPackage -Online | |
# // ============ | |
# // Begin Config | |
# // ============ | |
# Remove (Almost All) Inbox Universal Apps: | |
If ($StartApps -eq "False") | |
{ | |
# Disable "Consumer Features" (aka downloading apps from the internet automatically) | |
New-Item -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\' -Name 'CloudContent' | Out-Null | |
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent' -Name 'DisableWindowsConsumerFeatures' -PropertyType DWORD -Value '1' | Out-Null | |
# Disable the "how to use Windows" contextual popups | |
New-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent' -Name 'DisableSoftLanding' -PropertyType DWORD -Value '1' | Out-Null | |
Write-Host "Removing (most) built-in Universal Apps..." -ForegroundColor Yellow | |
Write-Host "" | |
ForEach ($App in $Apps) | |
{ | |
# Help / "Get" Apps | |
If ($App.DisplayName -eq "Microsoft.BingFinance") | |
{ | |
Write-Host "Removing Finance App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.BingNews") | |
{ | |
Write-Host "Removing News App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.BingSports") | |
{ | |
Write-Host "Removing Sports App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.Getstarted") | |
{ | |
Write-Host "Removing Get Started App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.SkypeApp") | |
{ | |
Write-Host "Removing Get Skype App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.MicrosoftOfficeHub") | |
{ | |
Write-Host "Removing Get Office App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
# Games / XBox apps | |
If ($App.DisplayName -eq "Microsoft.XboxApp") | |
{ | |
Write-Host "Removing XBox App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.ZuneMusic") | |
{ | |
Write-Host "Removing Groove Music App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.ZuneVideo") | |
{ | |
Write-Host "Removing Movies & TV App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.MicrosoftSolitaireCollection") | |
{ | |
Write-Host "Removing Microsoft Solitaire Collection App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
# Others | |
If ($App.DisplayName -eq "Microsoft.3DBuilder") | |
{ | |
Write-Host "Removing 3D Builder App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.People") | |
{ | |
Write-Host "Removing People App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.WindowsPhone") | |
{ | |
Write-Host "Removing Phone Companion App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.Office.Sway") | |
{ | |
Write-Host "Removing Office Sway App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.ConnectivityStore") | |
{ | |
Write-Host "Removing Connectivity Store helper App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
} | |
Start-Sleep -Seconds 5 | |
Write-Host "" | |
Write-Host "" | |
# Remove (the rest of the) Inbox Universal Apps: | |
If ($AllStartApps -eq "False") | |
{ | |
Write-Host "Removing (the rest of the) built-in Universal Apps..." -ForegroundColor Magenta | |
Write-Host "" | |
ForEach ($App in $Apps) | |
{ | |
If ($App.DisplayName -eq "Microsoft.Office.OneNote") | |
{ | |
Write-Host "Removing OneNote App..." -ForegroundColor Magenta | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
If ($App.DisplayName -eq "Microsoft.CommsPhone") | |
{ | |
Write-Host "Removing CommsPhone helper App..." -ForegroundColor Yellow | |
Remove-AppxProvisionedPackage -Online -PackageName $App.PackageName | Out-Null | |
Remove-AppxPackage -Package $App.PackageName | Out-Null | |
} | |
} | |
Start-Sleep -Seconds 5 | |
Write-Host "" | |
Write-Host "" | |
} | |
} | |
# Set PeerCaching to Disabled (0) or Local Network PCs only (1): | |
If ($PeerCache -eq "False") | |
{ | |
Write-Host "Disabling PeerCaching..." -ForegroundColor Yellow | |
Write-Host "" | |
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config' -Name 'DODownloadMode' -Value '0' | |
} | |
Else | |
{ | |
Write-Host "Configuring PeerCaching..." -ForegroundColor Cyan | |
Write-Host "" | |
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config' -Name 'DODownloadMode' -Value '1' | |
} | |
# Disable First Logon Animation | |
Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\Policies\System' -Name 'EnableFirstLogonAnimation' -Value '0' | |
# Disable Services: | |
Write-Host "Configuring Services..." -ForegroundColor Cyan | |
Write-Host "" | |
Write-Host "Disabling Xbox Live Auth Manager Service..." -ForegroundColor Cyan | |
Set-Service XblAuthManager -StartupType Disabled | |
Write-Host "Disabling Xbox Live Game Save Service..." -ForegroundColor Cyan | |
Set-Service XblGameSave -StartupType Disabled | |
Write-Host "Disabling Xbox Live Networking Service Service..." -ForegroundColor Cyan | |
Set-Service XboxNetApiSvc -StartupType Disabled | |
Write-Host "" | |
# Delete All Desktop Icons | |
Remove-Item C:\Users\Public\Desktop\*lnk -Force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment