Skip to content

Commit d22e166

Browse files
committed
feat: add 11 new PowerShell utility scripts
1 parent a08771c commit d22e166

11 files changed

+1815
-0
lines changed

PowerShell/Admin.ps1

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]'Administrator')) {
2+
Write-Host "You didn't run this script as an Administrator. This script will self elevate to run as an Administrator and continue."
3+
Start-Sleep 1
4+
Write-Host " 3"
5+
Start-Sleep 1
6+
Write-Host " 2"
7+
Start-Sleep 1
8+
Write-Host " 1"
9+
Start-Sleep 1
10+
Start-Process powershell.exe -ArgumentList ("-NoProfile -ExecutionPolicy Bypass -File `"{0}`"" -f $PSCommandPath) -Verb RunAs
11+
Exit
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
New-LabDefinition -Name GettingStarted -DefaultVirtualizationEngine HyperV
2+
Add-LabMachineDefinition -Name FirstServer -OperatingSystem 'Windows Server 2016 SERVERSTANDARD'
3+
Install-Lab
4+
Show-LabDeploymentSummary
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
If (!(Get-Module -Name AutomatedLab)) { Install-Module -Name AutomatedLab -Force -AllowClobber }
2+
3+
$AutoLabDir = "E:\LabSources"
4+
$AutoLabISODir = Join-Path $AutoLabDir "ISOs"
5+
6+
Get-LabAvailableOperatingSystem -Path $AutoLabDir
7+
8+
9+
10+

PowerShell/Debloat/Debloat-All.ps1

+1,002
Large diffs are not rendered by default.

PowerShell/Debloat/Debloat.ps1

+269
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,269 @@
1+
[CmdletBinding(SupportsShouldProcess)]
2+
param
3+
(
4+
[Parameter(ValueFromPipeline=$true)][switch]$RunDefaults,
5+
[Parameter(ValueFromPipeline=$true)][switch]$RunWin11Defaults,
6+
[Parameter(ValueFromPipeline=$true)][switch]$RemoveApps,
7+
[Parameter(ValueFromPipeline=$true)][switch]$DisableOnedrive,
8+
[Parameter(ValueFromPipeline=$true)][switch]$Disable3dObjects,
9+
[Parameter(ValueFromPipeline=$true)][switch]$DisableMusic,
10+
[Parameter(ValueFromPipeline=$true)][switch]$DisableBingSearches,
11+
[Parameter(ValueFromPipeline=$true)][switch]$DisableLockscreenTips,
12+
[Parameter(ValueFromPipeline=$true)][switch]$DisableWindowsSuggestions,
13+
[Parameter(ValueFromPipeline=$true)][switch]$DisableIncludeInLibrary,
14+
[Parameter(ValueFromPipeline=$true)][switch]$DisableGiveAccessTo,
15+
[Parameter(ValueFromPipeline=$true)][switch]$DisableShare
16+
)
17+
18+
function RemoveApps
19+
{
20+
Write-Output "> Removing pre-installed windows 10 apps..."
21+
22+
$apps = @(
23+
# These apps will be uninstalled by default:
24+
#
25+
# If you wish to KEEP any of the apps below simply add a # character
26+
# in front of the specific app in the list below.
27+
"*Microsoft.GetHelp*"
28+
"*Microsoft.Getstarted*"
29+
"*Microsoft.WindowsFeedbackHub*"
30+
"*Microsoft.BingNews*"
31+
"*Microsoft.BingFinance*"
32+
"*Microsoft.BingSports*"
33+
"*Microsoft.BingWeather*"
34+
"*Microsoft.BingTranslator*"
35+
"*Microsoft.MicrosoftOfficeHub*"
36+
"*Microsoft.Office.OneNote*"
37+
"*Microsoft.MicrosoftStickyNotes*"
38+
"*Microsoft.SkypeApp*"
39+
"*Microsoft.OneConnect*"
40+
"*Microsoft.Messaging*"
41+
"*Microsoft.WindowsSoundRecorder*"
42+
"*Microsoft.ZuneMusic*"
43+
"*Microsoft.ZuneVideo*"
44+
"*Microsoft.MixedReality.Portal*"
45+
"*Microsoft.3DBuilder*"
46+
"*Microsoft.Microsoft3DViewer*"
47+
"*Microsoft.Print3D*"
48+
"*Microsoft.549981C3F5F10*" #Cortana app
49+
"*Microsoft.MicrosoftSolitaireCollection*"
50+
"*Microsoft.Asphalt8Airborne*"
51+
"*king.com.BubbleWitch3Saga*"
52+
"*king.com.CandyCrushSodaSaga*"
53+
"*king.com.CandyCrushSaga*"
54+
55+
56+
57+
# These apps will NOT be uninstalled by default:
58+
#
59+
# If you wish to REMOVE any of the apps below simply remove the #
60+
# character in front of the specific app in the list below.
61+
#"*Microsoft.WindowsStore*" # NOTE: This app cannot be reinstalled!
62+
#"*Microsoft.WindowsCalculator*"
63+
#"*Microsoft.Windows.Photos*"
64+
#"*Microsoft.WindowsCamera*"
65+
#"*Microsoft.WindowsAlarms*"
66+
#"*Microsoft.WindowsMaps*"
67+
#"*microsoft.windowscommunicationsapps*" # Mail & Calendar
68+
#"*Microsoft.People*"
69+
#"*Microsoft.ScreenSketch*"
70+
#"*Microsoft.MSPaint*" # Paint 3D
71+
#"*Microsoft.YourPhone*"
72+
#"*Microsoft.Xbox.TCUI*"
73+
#"*Microsoft.XboxApp*"
74+
#"*Microsoft.XboxGameOverlay*"
75+
#"*Microsoft.XboxGamingOverlay*"
76+
#"*Microsoft.XboxIdentityProvider*"
77+
#"*Microsoft.XboxSpeechToTextOverlay*" # NOTE: This app may not be able to be reinstalled!
78+
)
79+
80+
foreach ($app in $apps) {
81+
Write-Output "Attempting to remove $app"
82+
83+
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
84+
}
85+
}
86+
87+
function RegImport
88+
{
89+
param
90+
(
91+
$Message,
92+
$Path
93+
)
94+
95+
Write-Output $Message
96+
reg import $path
97+
}
98+
99+
if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or (($PSBoundParameters.Count -eq 1) -and ($PSBoundParameters.ContainsKey('WhatIf') -or $PSBoundParameters.ContainsKey('Confirm') -or $PSBoundParameters.ContainsKey('Verbose'))))
100+
{
101+
if($RunDefaults)
102+
{
103+
$Mode = '1';
104+
}
105+
elseif($RunWin11Defaults)
106+
{
107+
$Mode = '2';
108+
}
109+
else
110+
{
111+
Clear
112+
Write-Output "-------------------------------------------------------------------------------------------"
113+
Write-Output " Win10Debloat Script - Setup"
114+
Write-Output "-------------------------------------------------------------------------------------------"
115+
Write-Output "(1) Run Win10Debloat with the Windows 10 default settings"
116+
Write-Output "(2) Run Win10Debloat with the Windows 11 default settings"
117+
Write-Output "(3) Advanced: Choose which changes you want Win10Debloat to make"
118+
Write-Output ""
119+
120+
Do { $Mode = Read-Host "Please select an option (1/2/3)" }
121+
while ($Mode -ne '1' -and $Mode -ne '2' -and $Mode -ne '3')
122+
}
123+
124+
switch($Mode)
125+
{
126+
'1'
127+
{
128+
Clear
129+
Write-Output "-------------------------------------------------------------------------------------------"
130+
Write-Output " Win10Debloat Script - Windows 10 Default Configuration"
131+
Write-Output "-------------------------------------------------------------------------------------------"
132+
$PSBoundParameters.Add('RemoveApps', $RemoveApps)
133+
$PSBoundParameters.Add('Disable3dObjects', $Disable3dObjects)
134+
$PSBoundParameters.Add('DisableBingSearches', $DisableBingSearches)
135+
$PSBoundParameters.Add('DisableLockscreenTips', $DisableLockscreenTips)
136+
$PSBoundParameters.Add('DisableWindowsSuggestions', $DisableWindowsSuggestions)
137+
$PSBoundParameters.Add('DisableIncludeInLibrary', $DisableIncludeInLibrary)
138+
$PSBoundParameters.Add('DisableGiveAccessTo', $DisableGiveAccessTo)
139+
$PSBoundParameters.Add('DisableShare', $DisableShare)
140+
}
141+
'2'
142+
{
143+
Clear
144+
Write-Output "-------------------------------------------------------------------------------------------"
145+
Write-Output " Win10Debloat Script - Windows 11 Default Configuration"
146+
Write-Output "-------------------------------------------------------------------------------------------"
147+
$PSBoundParameters.Add('RemoveApps', $RemoveApps)
148+
$PSBoundParameters.Add('DisableBingSearches', $DisableBingSearches)
149+
$PSBoundParameters.Add('DisableLockscreenTips', $DisableLockscreenTips)
150+
$PSBoundParameters.Add('DisableWindowsSuggestions', $DisableWindowsSuggestions)
151+
}
152+
'3'
153+
{
154+
Clear
155+
Write-Output "-------------------------------------------------------------------------------------------"
156+
Write-Output " Win10Debloat Script - Advanced Configuration"
157+
Write-Output "-------------------------------------------------------------------------------------------"
158+
159+
if($( Read-Host -Prompt "Remove the pre-installed windows 10 apps? (y/n)" ) -eq 'y')
160+
{
161+
$PSBoundParameters.Add('RemoveApps', $RemoveApps)
162+
}
163+
164+
if($( Read-Host -Prompt "Hide the onedrive folder in windows explorer? (y/n)" ) -eq 'y')
165+
{
166+
$PSBoundParameters.Add('DisableOnedrive', $DisableOnedrive)
167+
}
168+
169+
if($( Read-Host -Prompt "Hide the 3D objects folder in windows explorer? (y/n)" ) -eq 'y')
170+
{
171+
$PSBoundParameters.Add('Disable3dObjects', $Disable3dObjects)
172+
}
173+
174+
if($( Read-Host -Prompt "Hide the music folder in windows explorer? (y/n)" ) -eq 'y')
175+
{
176+
$PSBoundParameters.Add('DisableMusic', $DisableMusic)
177+
}
178+
179+
if($( Read-Host -Prompt "Disable bing in windows search? (y/n)" ) -eq 'y')
180+
{
181+
$PSBoundParameters.Add('DisableBingSearches', $DisableBingSearches)
182+
}
183+
184+
if($( Read-Host -Prompt "Disable tips & tricks on the lockscreen? (y/n)" ) -eq 'y')
185+
{
186+
$PSBoundParameters.Add('DisableLockscreenTips', $DisableLockscreenTips)
187+
}
188+
189+
if($( Read-Host -Prompt "Disable tips, tricks and suggestions in the startmenu and settings? (y/n)" ) -eq 'y')
190+
{
191+
$PSBoundParameters.Add('DisableWindowsSuggestions', $DisableWindowsSuggestions)
192+
}
193+
194+
if($( Read-Host -Prompt "Disable the 'Include in library' option in the context menu? (y/n)" ) -eq 'y')
195+
{
196+
$PSBoundParameters.Add('DisableIncludeInLibrary', $DisableIncludeInLibrary)
197+
}
198+
199+
if($( Read-Host -Prompt "Disable the 'Give access to' option in the context menu? (y/n)" ) -eq 'y')
200+
{
201+
$PSBoundParameters.Add('DisableGiveAccessTo', $DisableGiveAccessTo)
202+
}
203+
204+
if($( Read-Host -Prompt "Disable the 'Share' option in the context menu? (y/n)" ) -eq 'y')
205+
{
206+
$PSBoundParameters.Add('DisableShare', $DisableShare)
207+
}
208+
209+
Write-Output ""
210+
}
211+
}
212+
}
213+
else
214+
{
215+
Clear
216+
Write-Output "-------------------------------------------------------------------------------------------"
217+
Write-Output " Win10Debloat Script - Custom Configuration"
218+
Write-Output "-------------------------------------------------------------------------------------------"
219+
}
220+
221+
switch ($PSBoundParameters.Keys)
222+
{
223+
'RemoveApps'
224+
{
225+
RemoveApps
226+
}
227+
'DisableOnedrive'
228+
{
229+
RegImport "> Hiding the onedrive folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_Onedrive_Folder.reg
230+
}
231+
'Disable3dObjects'
232+
{
233+
RegImport "> Hiding the 3D objects folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_3D_Objects_Folder.reg
234+
}
235+
'DisableMusic'
236+
{
237+
RegImport "> Hiding the music folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_Music_folder.reg
238+
}
239+
'DisableBingSearches'
240+
{
241+
RegImport "> Disabling bing in windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Searches.reg
242+
}
243+
'DisableLockscreenTips'
244+
{
245+
RegImport "> Disabling tips & tricks on the lockscreen..." $PSScriptRoot\Regfiles\Disable_Lockscreen_Tips.reg
246+
}
247+
'DisableWindowsSuggestions'
248+
{
249+
RegImport "> Disabling tips, tricks and suggestions in the startmenu and settings..." $PSScriptRoot\Regfiles\Disable_Windows_Suggestions.reg
250+
}
251+
'DisableIncludeInLibrary'
252+
{
253+
RegImport "> Disabling 'Include in library' in the context menu..." $PSScriptRoot\Regfiles\Disable_Include_in_library_from_context_menu.reg
254+
}
255+
'DisableGiveAccessTo'
256+
{
257+
RegImport "> Disabling 'Give access to' in the context menu..." $PSScriptRoot\Regfiles\Disable_Give_access_to_context_menu.reg
258+
}
259+
'DisableShare'
260+
{
261+
RegImport "> Disabling 'Share' in the context menu..." $PSScriptRoot\Regfiles\Disable_Share_from_context_menu.reg
262+
}
263+
}
264+
265+
Write-Output ""
266+
Write-Output "Script completed! Please restart your PC to make sure all changes are properly applied."
267+
Write-Output ""
268+
Write-Output "Press any key to continue..."
269+
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

PowerShell/Debloat/Full-Debloat.ps1

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Write-Output "Attempting to launch script with admin privileges..."
2+
3+
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Unrestricted -File ""$PSScriptRoot\Win10Debloat.ps1""' -Verb RunAs}";
4+
5+
<#------------------------------------------------------------------------------------------------------------------------------------------------>
6+
It's possible to tweak the behaviour of the script by adding arguments to the ArgumentList, a full list of arguments is shown below.
7+
This has the added benefit that the script will run without requiring any user input during runtime, allowing you to automate the process.
8+
9+
The example below configures the script to only remove apps and disable bing in windows search:
10+
11+
PowerShell -NoProfile -ExecutionPolicy Unrestricted -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile
12+
-ExecutionPolicy Unrestricted
13+
-File ""$PSScriptRoot\Win10Debloat.ps1""
14+
-RemoveApps
15+
-DisableBingSearches'
16+
-Verb RunAs}";
17+
18+
Supported Arguments:
19+
-RunDefaults | Run the script with default settings
20+
-RemoveApps | Remove configured apps
21+
-DisableOnedrive | Hide the onedrive folder in the windows explorer sidebar.
22+
-Disable3dObjects | Hide the 3D objects folder under 'This pc' in windows explorer.
23+
-DisableMusic | Hide the music folder under 'This pc' in windows explorer.
24+
-DisableBingSearches | Disable bing in windows search.
25+
-DisableLockscreenTips | Disable tips & tricks on the lockscreen.
26+
-DisableWindowsSuggestions | Disable tips, tricks and suggestions in the startmenu and settings.
27+
-DisableIncludeInLibrary | Disable the 'Include in library' option in the context menu.
28+
-DisableGiveAccessTo | Disable the 'Give access to' option in the context menu.
29+
-DisableShare | Disable the 'Share' option in the context menu.
30+
<------------------------------------------------------------------------------------------------------------------------------------------------#>

0 commit comments

Comments
 (0)