Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- This is a script I wrote that will clean up a Windows 10 image of all the Microsoft bloat that can be removed/disabled. Read through the whole thing and understand what this script is doing. Read comments marked with "####"
- I use shorthand so this is what these mean when you see them
- sp = set-property = sets registry values
- rp = remove-property = removes registry values
- ri = remove item = removes files/folders/registry keys
- #>
- #### make sure you allow scripts to run through group policy, or with the following commands
- #### set-executionpolicy unrestricted -scope localmachine
- #### set-executionpolicy unrestricted -scope currentuser
- #### enable winrm (remote management)
- & winrm quickconfig -quiet
- #### list of default applications to remove
- $rapps = @(
- "Microsoft.3DBuilder"
- "Microsoft.BingFinance"
- "Microsoft.BingNews"
- "Microsoft.BingSports"
- "Microsoft.BingWeather"
- "Microsoft.Getstarted"
- "Microsoft.MicrosoftOfficeHub"
- "Microsoft.MicrosoftSolitaireCollection"
- "Microsoft.Office.OneNote"
- "Microsoft.People"
- "Microsoft.SkypeApp"
- "Microsoft.Windows.Photos"
- "Microsoft.WindowsCamera"
- "microsoft.windowscommunicationsapps"
- "Microsoft.WindowsMaps"
- "Microsoft.WindowsPhone"
- "Microsoft.WindowsSoundRecorder"
- "Microsoft.WindowsStore"
- "Microsoft.XboxApp"
- "Microsoft.ZuneMusic"
- "Microsoft.ZuneVideo"
- )
- #### list of services to disable
- $dsvcs = @(
- "BITS"
- "DeviceAssociationService"
- "DPS"
- "WdiServiceHost"
- "WdiSystemHost"
- "DiagTrack"
- "fdPHost"
- "HomeGroupProvider"
- "HomeGroupListener"
- "wscsvc"
- "ShellHWDetection"
- "SSDPSRV"
- "SysMain"
- "wcncsvc"
- "AJRouter"
- "ALG"
- "BDESVC"
- "BthHFSrv"
- "bthserv"
- "PeerDistSvc"
- "EFS"
- "Fax"
- "SharedAccess"
- "CscService"
- "defragsvc"
- "RetailDemo"
- "SensrSvc"
- "upnphost"
- "WerSvc"
- "WMPNetworkSvc"
- "WbioSrvc"
- "wuauserv"
- "WlanSvc"
- "WwanSvc"
- "XblAuthManager"
- "XblGameSave"
- "XboxNetApiSvc"
- )
- #### list of scheduled tasks to disable
- $dtasks = "`"taskpath`",`"taskname`"
- `"\Microsoft\Windows\Application Experience\`",`"Microsoft Compatibility Appraiser`"
- `"\Microsoft\Windows\Application Experience\`",`"ProgramDataUpdater`"
- `"\Microsoft\Windows\Application Experience\`",`"StartupAppTask`"
- `"\Microsoft\Windows\Autochk\`",`"Proxy`"
- `"\Microsoft\Windows\Customer Experience Improvement Program\`",`"Consolidator`"
- `"\Microsoft\Windows\Customer Experience Improvement Program\`",`"KernelCeipTask`"
- `"\Microsoft\Windows\Customer Experience Improvement Program\`",`"Uploader`"
- `"\Microsoft\Windows\Customer Experience Improvement Program\`",`"UsbCeip`"
- `"\Microsoft\Windows\Shell\`",`"FamilySafetyMonitor`"
- `"\Microsoft\Windows\Shell\`",`"FamilySafetyRefresh`"
- `"\Microsoft\Windows\Windows Filtering Platform\`",`"BfeOnServiceStartTypeChange`"
- `"\Microsoft\Windows\Diagnosis\`",`"Scheduled`"
- `"\Microsoft\Windows\DiskDiagnostic\`",`"Microsoft-Windows-DiskDiagnosticDataCollector`"
- `"\Microsoft\Windows\DiskDiagnostic\`",`"Microsoft-Windows-DiskDiagnosticResolver`"
- `"\Microsoft\Windows\Defrag\`",`"ScheduledDefrag`"
- `"\Microsoft\Windows\FileHistory\`",`"File History (maintenance mode)`"
- `"\Microsoft\Windows\Maintenance\`",`"WinSAT`"
- `"\Microsoft\Windows\MemoryDiagnostic\`",`"ProcessMemoryDiagnosticEvents`"
- `"\Microsoft\Windows\MemoryDiagnostic\`",`"RunFullMemoryDiagnostic`"
- `"\Microsoft\Windows\Power Efficiency Diagnostics\`",`"AnalyzeSystem`"
- `"\Microsoft\Windows\RecoveryEnvironment\`",`"VerifyWinRE`"
- `"\Microsoft\Windows\SystemRestore\`",`"SR`"
- `"\Microsoft\Windows\WDI\`",`"ResolutionHost`"" | ConvertFrom-Csv
- #### removes junk applications - you may see some red errors on the screen when this runs - you can ignore them
- foreach ($rapp in $rapps) {
- Get-AppxPackage $rapp | Remove-AppxPackage | Out-Null
- Remove-ProvisionedAppxPackage -Online -PackageName (Get-ProvisionedAppxPackage -Online | ?{$_.DisplayName -eq $rapp}).packagename
- }
- #### stops and disables junk services (BITS is set to Manual)
- foreach ($dsvc in $dsvcs) {
- if ($dsvc -eq "BITS") {
- if ((Get-Service $dsvc).Status -eq "running") {Stop-Service $dsvc}
- Set-Service -Name $dsvc -StartupType Manual
- } else {
- if ((Get-Service $dsvc).Status -eq "running") {Stop-Service $dsvc}
- Set-Service -Name $dsvc -StartupType Disabled
- }
- }
- #### disables tasks
- foreach ($dtask in $dtasks) {
- Disable-ScheduledTask -TaskPath $dtask.taskpath -TaskName $dtask.taskname
- }
- #### Registry Tweaks - ignore any errors due to registry keys not being present for remove-property (rp)
- sp HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters -Name DisableTaskOffload -Value 1 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System -Name EnableFirstLogonAnimation -Value 0 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control\Windows -Name ErrorMode -Value 2 -Type DWord
- sp HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name DisableLogonBackgroundImage -Value 1 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout -Name EnableAutoLayout -Value 0 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer -Name NoRemoteRecursiveEvents -Value 1 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\SQMClient\Windows -Name CEIPEnable -Value 0 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control -Name ServicesPipeTimeout -Value 120000 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\ImmersiveShell -Name UseActionCenterExperience -Value 0 -Type DWord
- #### remove junk that can delay logon
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{89B4C1CD-B018-4511-B0A1-5476DBF70820}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{2C7339CF-2B09-4501-B3F3-F3508C9228ED}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{44BBA840-CC51-11CF-AAFA-00AA00B6015C}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{6BF52A52-394A-11d3-B153-00C04F79FAA6}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4340}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{89820200-ECBD-11cf-8B85-00AA005B4383}' -Name StubPath
- rp 'HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{22d6f312-b0f6-11d0-94ab-0080c74c7e95}' -Name StubPath
- ri 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Recurse -Force
- ri 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Recurse -Force
- #### create keys if they dont exist
- if (!(Test-Path HKLM:\SOFTWARE\Policies\Microsoft)) {md HKLM:\SOFTWARE\Policies\Microsoft | Out-Null}
- if (!(Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows)) {md HKLM:\SOFTWARE\Policies\Microsoft\Windows | Out-Null}
- if (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search')) {md 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' | Out-Null}
- if (!(Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Skydrive)) {md HKLM:\SOFTWARE\Policies\Microsoft\Windows\Skydrive | Out-Null}
- #### disable skydrive - local policy
- sp HKLM:\SOFTWARE\Policies\Microsoft\Windows\Skydrive -Name DisableFileSync -Value 1 -Type DWord
- sp HKLM:\SOFTWARE\Policies\Microsoft\Windows\Skydrive -Name DisableLibrariesDefaultSaveToSkyDrive -Value 1 -Type DWord
- if (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender')) {md 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender' | Out-Null}
- #### disable windows defender
- sp 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender' -Name DisableAntiSpyware -Value 1 -Type DWord
- #### to disable cortana or not... uncomment the next line if you want her disabled
- #### sp 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' -Name AllowCortana -Value 0 -Type DWord
- #### do not allow search to use location or search the web - next two lines
- sp 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' -Name AllowSearchToUseLocation -Value 0 -Type DWord
- sp 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search' -Name ConnectedSearchUseWeb -Value 0 -Type DWord
- #### create keys if they dont exist
- if (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer')){md 'HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer' | Out-Null}
- if (!(Test-Path 'HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main')) {md 'HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main' | Out-Null}
- #### various tweaks
- sp 'HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main' -Name DisableFirstRunCustomize -Value 1 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem -Name NtfsDisableLastAccessUpdate -Value 1 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl -Name CrashDumpEnabled -Value 0 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl -Name LogEvent -Value 0 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl -Name SendAlert -Value 0 -Type DWord
- sp HKLM:\SOFTWARE\Microsoft\Dfrg\BootOptimizeFunction -Name Enable -Value N -Type String
- sp HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\OptimalLayout -Name EnableAutoLayout -Value 0 -Type DWord
- sp HKLM:\SYSTEM\CurrentControlSet\Services\disk -Name TimeOutValue -Value 200 -Type DWord
- sp 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management' -Name ClearPageFileAtShutdown -Value 0 -Type DWord
- #### this turns off the vmware tools tray - comment out the next line if needed
- sp 'HKLM:\SOFTWARE\VMware, Inc.\VMware Tools' -Name ShowTray -Value 0 -Type DWord
- #### more tweaks in hkcu
- sp HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_TrackDocs -Value 0 -Type DWord
- sp 'HKCU:\Control Panel\Desktop' -Name MenuShowDelay -Value 120 -Type DWord
- if (!(Test-Path HKCU:\SOFTWARE\Microsoft\Feeds)) {md HKCU:\SOFTWARE\Microsoft\Feeds | Out-Null}
- sp HKCU:\SOFTWARE\Microsoft\Feeds -Name SyncStatus -Value 0 -Type DWord
- #### I copy in "transcodedwallpaper.jpg" to the root of C: on my XD image - this sets it for the current user
- #### comment out the next line if you dont want to use that
- sp 'HKCU:\Control Panel\Desktop' -Name Wallpaper -Value "C:\transcodedwallpaper.jpg" -Type String
- sp HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchboxTaskbarMode -Value 1 -Type DWord
- #### editing the default ntuser.dat file!
- & reg load HKLM\asdf C:\users\Default\NTUSER.DAT
- sp HKLM:\asdf\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name Start_TrackDocs -Value 0 -Type DWord
- sp 'HKLM:\asdf\Control Panel\Desktop' -Name MenuShowDelay -Value 120 -Type DWord
- if (!(Test-Path HKLM:\asdf\SOFTWARE\Microsoft\Feeds)) {md HKLM:\asdf\SOFTWARE\Microsoft\Feeds | Out-Null}
- sp HKLM:\asdf\SOFTWARE\Microsoft\Feeds -Name SyncStatus -Value 0 -Type DWord
- #### this sets the default wallpaper - comment out/delete the next line if not needed
- sp 'HKLM:\asdf\Control Panel\Desktop' -Name Wallpaper -Value "C:\transcodedwallpaper.jpg" -Type String
- sp HKLM:\asdf\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name SearchboxTaskbarMode -Value 1 -Type DWord
- rp HKLM:\asdf\SOFTWARE\Microsoft\Windows\CurrentVersion\Run -Name OneDriveSetup
- #### wait half a second and unload the default ntuser.dat file - after the script runs be sure that HKLM:\asdf does not exist in the registy
- #### if it does - unload the hive
- Start-Sleep -m 500
- & reg unload HKLM\asdf
- #### power configuration
- & powercfg -change -disk-timeout-ac 0
- & powercfg -change -disk-timeout-dc 0
- & powercfg -H OFF
- & powercfg -change -monitor-timeout-ac 0
- & powercfg -change -monitor-timeout-dc 0
- #### disable restore
- Disable-ComputerRestore -Drive c:\
- #### disable boot logging
- & bcdedit /bootdebug off
- & bcdedit /debug off
- & bcdedit /set bootlog no
- #### uninstall onedrive
- $app = start-process C:\Windows\SysWOW64\OneDriveSetup.exe -ArgumentList "/uninstall" -PassThru
- Wait-Process $app.Id
- #### onedrive registry entries that are needed after uninstalling the app (if these do not exist you get an error when trying to rename files\folders)
- if (!(Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}')) {md 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' | Out-Null}
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Attributes -Value 1 -Type DWord
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Category -Value 4 -Type DWord
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name DefinitionFlags -Value 40 -Type DWord
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name LocalRedirectOnly -Value 1 -Type DWord
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Name -Value OneDrive -Type String
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name ParentFolder -Value '{5E6C858F-0E22-4760-9AFE-EA3317B67173}' -Type String
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name ParsingName -Value 'shell:::{018D5C66-4533-4307-9B53-224DE2ED1FE6}' -Type String
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name RelativePath -Value OneDrive -Type String
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Icon -Value '%SystemRoot%\system32\imageres.dll,-1040' -Type ExpandString
- sp 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name LocalizedName -Value '@%SystemRoot%\System32\SettingSyncCore.dll,-1024' -Type ExpandString
- if (!(Test-Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}')) {md 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' | Out-Null}
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Attributes -Value 1 -Type DWord
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Category -Value 4 -Type DWord
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name DefinitionFlags -Value 40 -Type DWord
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name LocalRedirectOnly -Value 1 -Type DWord
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Name -Value OneDrive -Type String
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name ParentFolder -Value '{5E6C858F-0E22-4760-9AFE-EA3317B67173}' -Type String
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name ParsingName -Value 'shell:::{018D5C66-4533-4307-9B53-224DE2ED1FE6}' -Type String
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name RelativePath -Value OneDrive -Type String
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name Icon -Value '%SystemRoot%\system32\imageres.dll,-1040' -Type ExpandString
- sp 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{A52BBA46-E9E1-435f-B3D9-28DAA648C0F6}' -Name LocalizedName -Value '@%SystemRoot%\System32\SettingSyncCore.dll,-1024' -Type ExpandString
- New-PSDrive -Name HKCR -PSProvider Registry -Root HKCR | Out-Null
- sp 'HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}' -Name 'System.IsPinnedToNameSpaceTree' -Value 0 -Type DWord
- Remove-PSDrive -Name HKCR
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement