https://github.com/EntityTech/Windows-10-Debloat.git
I was just tired of all the junk Microsoft loads your Win 10 up with when it’s installed or booted up for the first time, so I started playing around with a few things in powershell and came up with this.
Please check out my code and critique if you can and if you see room for improvement then let me know
Also hopefully I’m posting this code correctly below
#########
##Allows the script to run with right click "run with powershell"
#########
Add-Type -AssemblyName PresentationCore,PresentationFramework
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator'))
{
Start-Process -FilePath powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
Exit
}
#########
##Ignore Error messages and setting some variables
#########
$ErrorActionPreference = 'silentlycontinue'
$ButtonType = [Windows.MessageBoxButton]::YesNo
$ErrorIcon = [Windows.MessageBoxImage]::Error
$OdBody = 'Do you want to get rid of OneDrive?'
$WarnBody = 'Warning, this will remove ALL default Windows 10 apps where you will ONLY have the Windows Store left, do you want to continue?'
$MessageTitle = 'Confirm Delete'
$WarnIcon = [Windows.MessageBoxImage]::Warning
#########
##Warning about the script
#########
$StartInput = [Windows.MessageBox]::Show($WarnBody,$MessageTitle,$ButtonType,$WarnIcon)
If ($StartInput -eq 'Yes')
{
#########
##Uninstall Bloat and all default windows apps except the store and prevents them from
##coming back on future users but does not delete the store.
#########
Get-AppxPackage -AllUsers | Where {($_.Name -notlike '*store*')} | Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where {($_.Name -notlike '*store*')} | Remove-AppxProvisionedPackage -Online
########
##The Registry path to prevent more apps from reinstalling later on.
########
$regPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent'
$regCDM = 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager'
New-Item -Path $regPath -Force
New-ItemProperty -Path $regPath -Name DisableWindowsConsumerFeatures -Value 1 -Force
Set-ItemProperty -Path $regCDM -Name ContentDeliveryAllowed -Value 0 -Force
Set-ItemProperty -Path $regCDM -Name OemPreInstalledAppsEnabled -Value 0 -Force
Set-ItemProperty -Path $regCDM -Name PreInstalledAppsEnabled -Value 0 -Force
Set-ItemProperty -Path $regCDM -Name PreInstalledAppsEverEnabled -Value 0 -Force
Set-ItemProperty -Path $regCDM -Name SilentInstalledAppsEnabled -Value 0 -Force
Set-ItemProperty -Path $regCDM -Name SystemPaneSuggestionsEnabled -Value 0 -Force
Remove-Item -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager\SuggestedApps
}
########
##Prompt to remove OneDrive from the computer.
########
$OdInput = [Windows.MessageBox]::Show($OdBody,$MessageTitle,$ButtonType,$ErrorIcon)
If ($OdInput -eq 'Yes')
{
New-PSDrive -PSProvider 'Registry' -Root 'HKEY_CLASSES_ROOT' -Name 'HKCR'
$regOneDrive = 'HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}'
$regTwoDrive = 'HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}'
$PathHereOne = Test-Path -Path $regOneDrive
$PathHereTwo = Test-Path -Path $regTwoDrive
Write-Output -InputObject 'Stopping OneDrive.'
& "$env:windir\system32\taskkill.exe" /F /IM 'OneDrive.exe'
& "$env:windir\system32\taskkill.exe" /F /IM 'explorer.exe'
Write-Output -InputObject 'Uninstalling OneDrive from the computer.'
If (Test-Path -Path "$env:systemroot\System32\OneDriveSetup.exe")
{
& "$env:systemroot\System32\OneDriveSetup.exe" /uninstall
}
If (Test-Path -Path "$env:systemroot\SysWOW64\OneDriveSetup.exe")
{
& "$env:systemroot\SysWOW64\OneDriveSetup.exe" /uninstall
}
Write-Output -InputObject 'Getting rid of extra files.'
Remove-Item -Recurse -Force -Path "$env:localappdata\Microsoft\OneDrive"
Remove-Item -Recurse -Force -Path "$env:programdata\Microsoft OneDrive"
Remove-Item -Recurse -Force -Path "$env:HOMEDRIVE\OneDriveTemp"
Remove-Item -Recurse -Force -Path "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk"
Remove-Item -Recurse -Force -Path "$env:userprofile\OneDrive"
Remove-Item -Recurse -Force -Path "$env:userprofile\Links\OneDrive"
Remove-Item -Recurse -Force -Path "$env:windir\SysWOW64\OneDriveSetup"
Write-Output -InputObject 'Checking to remove OneDrive from sidebar in windows explorer.'
If ($PathHereOne -eq $True)
{
Set-ItemProperty -Path $regOneDrive -Name System.IsPinnedToNameSpaceTree -Value 0 -Force
}
If ($PathHereOne -eq $False)
{
New-Item -Path $regOneDrive -Force
New-ItemProperty -Path $regOneDrive -Name System.IsPinnedToNameSpaceTree -Value 0 -Force
}
If ($PathHereTwo -eq $True)
{
Set-ItemProperty -Path $regTwoDrive -Name System.IsPinnedToNameSpaceTree -Value 0 -Force
}
If ($PathHereTwo -eq $False)
{
New-Item -Path $regTwoDrive -Force
New-ItemProperty -Path $regTwoDrive -Name System.IsPinnedToNameSpaceTree -Value 0 -Force
}
Write-Output -InputObject 'Restarting explorer that got shut down before.'
& "$env:windir\explorer.exe"
Remove-PSDrive -Name 'HKCR'
}
########
##Returns the execution policy to default
########
Set-ExecutionPolicy -ExecutionPolicy Restricted -Force