-
-
Notifications
You must be signed in to change notification settings - Fork 651
/
Get.ps1
107 lines (92 loc) · 4.04 KB
/
Get.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
param (
[switch]$Silent,
[switch]$Verbose,
[switch]$Sysprep,
[switch]$RunAppConfigurator,
[switch]$RunDefaults, [switch]$RunWin11Defaults,
[switch]$RemoveApps,
[switch]$RemoveAppsCustom,
[switch]$RemoveGamingApps,
[switch]$RemoveCommApps,
[switch]$RemoveDevApps,
[switch]$RemoveW11Outlook,
[switch]$ForceRemoveEdge,
[switch]$DisableDVR,
[switch]$DisableTelemetry,
[switch]$DisableBingSearches, [switch]$DisableBing,
[switch]$DisableDesktopSpotlight,
[switch]$DisableLockscrTips, [switch]$DisableLockscreenTips,
[switch]$DisableWindowsSuggestions, [switch]$DisableSuggestions,
[switch]$ShowHiddenFolders,
[switch]$ShowKnownFileExt,
[switch]$HideDupliDrive,
[switch]$TaskbarAlignLeft,
[switch]$HideSearchTb, [switch]$ShowSearchIconTb, [switch]$ShowSearchLabelTb, [switch]$ShowSearchBoxTb,
[switch]$HideTaskview,
[switch]$DisableCopilot,
[switch]$DisableRecall,
[switch]$DisableWidgets,
[switch]$HideWidgets,
[switch]$DisableChat,
[switch]$HideChat,
[switch]$ClearStart,
[switch]$ClearStartAllUsers,
[switch]$RevertContextMenu,
[switch]$HideHome,
[switch]$HideGallery,
[switch]$ExplorerToHome,
[switch]$ExplorerToThisPC,
[switch]$ExplorerToDownloads,
[switch]$ExplorerToOneDrive,
[switch]$DisableOnedrive, [switch]$HideOnedrive,
[switch]$Disable3dObjects, [switch]$Hide3dObjects,
[switch]$DisableMusic, [switch]$HideMusic,
[switch]$DisableIncludeInLibrary, [switch]$HideIncludeInLibrary,
[switch]$DisableGiveAccessTo, [switch]$HideGiveAccessTo,
[switch]$DisableShare, [switch]$HideShare
)
# Show error if current powershell environment does not have LanguageMode set to FullLanguage
if ($ExecutionContext.SessionState.LanguageMode -ne "FullLanguage") {
Write-Host "Error: Win11Debloat is unable to run on your system. Powershell execution is restricted by security policies" -ForegroundColor Red
Write-Output ""
Write-Output "Press enter to exit..."
Read-Host | Out-Null
Exit
}
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win11Debloat Script - Get"
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output "> Downloading Win11Debloat..."
# Download latest version of Win11Debloat from github as zip archive
Invoke-WebRequest http://github.com/raphire/win11debloat/archive/master.zip -OutFile "$env:TEMP/win11debloat-temp.zip"
# Remove old script folder if it exists, except for CustomAppsList and SavedSettings files
if (Test-Path "$env:TEMP/Win11Debloat/Win11Debloat-master") {
Write-Output ""
Write-Output "> Cleaning up old Win11Debloat folder..."
Get-ChildItem -Path "$env:TEMP/Win11Debloat/Win11Debloat-master" -Exclude CustomAppsList,SavedSettings | Remove-Item -Recurse -Force
}
Write-Output ""
Write-Output "> Unpacking..."
# Unzip archive to Win11Debloat folder
Expand-Archive "$env:TEMP/win11debloat-temp.zip" "$env:TEMP/Win11Debloat"
# Remove archive
Remove-Item "$env:TEMP/win11debloat-temp.zip"
# Make list of arguments to pass on to the script
$arguments = $($PSBoundParameters.GetEnumerator() | ForEach-Object {"-$($_.Key)"})
Write-Output ""
Write-Output "> Running Win11Debloat..."
# Run Win11Debloat script with the provided arguments
$debloatProcess = Start-Process powershell.exe -PassThru -ArgumentList "-executionpolicy bypass -File $env:TEMP\Win11Debloat\Win11Debloat-master\Win11Debloat.ps1 $arguments" -Verb RunAs
# Wait for the process to finish before continuing
if ($null -ne $debloatProcess) {
$debloatProcess.WaitForExit()
}
# Remove all remaining script files, except for CustomAppsList and SavedSettings files
if (Test-Path "$env:TEMP/Win11Debloat/Win11Debloat-master") {
Write-Output ""
Write-Output "> Cleaning up..."
# Cleanup, remove Win11Debloat directory
Get-ChildItem -Path "$env:TEMP/Win11Debloat/Win11Debloat-master" -Exclude CustomAppsList,SavedSettings | Remove-Item -Recurse -Force
}
Write-Output ""