Linting and Formatting (#3)

* Formatted Markdown
* Formatted PowerShell
* Removed PowerShell aliases
This commit is contained in:
Jason Krause
2023-05-15 16:38:11 -06:00
committed by GitHub
parent 80fdfbf0ee
commit 671565425c
2 changed files with 94 additions and 124 deletions

View File

@@ -3,28 +3,27 @@
[CmdletBinding(SupportsShouldProcess)]
param
(
[Parameter(ValueFromPipeline=$true)][switch]$RunDefaults,
[Parameter(ValueFromPipeline=$true)][switch]$RunWin11Defaults,
[Parameter(ValueFromPipeline=$true)][switch]$RemoveApps,
[Parameter(ValueFromPipeline=$true)][switch]$DisableTelemetry,
[Parameter(ValueFromPipeline=$true)][switch]$DisableBingSearches,
[Parameter(ValueFromPipeline=$true)][switch]$DisableBing,
[Parameter(ValueFromPipeline=$true)][switch]$DisableLockscreenTips,
[Parameter(ValueFromPipeline=$true)][switch]$DisableWindowsSuggestions,
[Parameter(ValueFromPipeline=$true)][switch]$DisableSuggestions,
[Parameter(ValueFromPipeline=$true)][switch]$DisableChat,
[Parameter(ValueFromPipeline=$true)][switch]$DisableWidgets,
[Parameter(ValueFromPipeline=$true)][switch]$DisableOnedrive,
[Parameter(ValueFromPipeline=$true)][switch]$Disable3dObjects,
[Parameter(ValueFromPipeline=$true)][switch]$DisableMusic,
[Parameter(ValueFromPipeline=$true)][switch]$DisableIncludeInLibrary,
[Parameter(ValueFromPipeline=$true)][switch]$DisableGiveAccessTo,
[Parameter(ValueFromPipeline=$true)][switch]$DisableShare
[Parameter(ValueFromPipeline = $true)][switch]$RunDefaults,
[Parameter(ValueFromPipeline = $true)][switch]$RunWin11Defaults,
[Parameter(ValueFromPipeline = $true)][switch]$RemoveApps,
[Parameter(ValueFromPipeline = $true)][switch]$DisableTelemetry,
[Parameter(ValueFromPipeline = $true)][switch]$DisableBingSearches,
[Parameter(ValueFromPipeline = $true)][switch]$DisableBing,
[Parameter(ValueFromPipeline = $true)][switch]$DisableLockscreenTips,
[Parameter(ValueFromPipeline = $true)][switch]$DisableWindowsSuggestions,
[Parameter(ValueFromPipeline = $true)][switch]$DisableSuggestions,
[Parameter(ValueFromPipeline = $true)][switch]$DisableChat,
[Parameter(ValueFromPipeline = $true)][switch]$DisableWidgets,
[Parameter(ValueFromPipeline = $true)][switch]$DisableOnedrive,
[Parameter(ValueFromPipeline = $true)][switch]$Disable3dObjects,
[Parameter(ValueFromPipeline = $true)][switch]$DisableMusic,
[Parameter(ValueFromPipeline = $true)][switch]$DisableIncludeInLibrary,
[Parameter(ValueFromPipeline = $true)][switch]$DisableGiveAccessTo,
[Parameter(ValueFromPipeline = $true)][switch]$DisableShare
)
# Removes all apps in the list
function RemoveApps
{
function RemoveApps {
Write-Output "> Removing pre-installed windows 10 apps..."
$apps = @(
@@ -111,13 +110,12 @@ function RemoveApps
Get-AppxPackage -Name $app -AllUsers | Remove-AppxPackage
Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -like $app} | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }
Get-AppxProvisionedPackage -Online | Where-Object { $_.PackageName -like $app } | ForEach-Object { Remove-ProvisionedAppxPackage -Online -AllUsers -PackageName $_.PackageName }
}
}
# Import & execute regfile
function RegImport
{
function RegImport {
param
(
$Message,
@@ -129,20 +127,16 @@ function RegImport
}
# Change mode based on provided parameters or user input
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'))))
{
if($RunDefaults)
{
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')))) {
if ($RunDefaults) {
$Mode = '1';
}
elseif($RunWin11Defaults)
{
elseif ($RunWin11Defaults) {
$Mode = '2';
}
else
{
else {
Do {
Clear
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat Script - Setup"
Write-Output "-------------------------------------------------------------------------------------------"
@@ -155,8 +149,8 @@ if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ((
Write-Output ""
$Mode = Read-Host "Please select an option (1/2/3/0)"
if($Mode -eq '0') {
Clear
if ($Mode -eq '0') {
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat - Information"
Write-Output "-------------------------------------------------------------------------------------------"
@@ -198,11 +192,9 @@ if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ((
}
# Add execution parameters based on the mode
switch($Mode)
{
'1'
{
Clear
switch ($Mode) {
'1' {
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat Script - Windows 10 Default Configuration"
Write-Output "-------------------------------------------------------------------------------------------"
@@ -219,9 +211,8 @@ if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ((
$PSBoundParameters.Add('DisableShare', $DisableShare)
}
'2'
{
Clear
'2' {
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat Script - Windows 11 Default Configuration"
Write-Output "-------------------------------------------------------------------------------------------"
@@ -234,83 +225,66 @@ if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ((
$PSBoundParameters.Add('DisableWidgets', $DisableWidgets)
}
'3'
{
Clear
'3' {
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat Script - Custom Configuration"
Write-Output "-------------------------------------------------------------------------------------------"
if($( Read-Host -Prompt "Remove the pre-installed windows 10 apps? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Remove the pre-installed windows 10 apps? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('RemoveApps', $RemoveApps)
}
if($( Read-Host -Prompt "Disable telemetry, diagnostic data and targeted ads? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable telemetry, diagnostic data and targeted ads? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableTelemetry', $DisableTelemetry)
}
if($( Read-Host -Prompt "Disable bing & cortana in windows search? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable bing & cortana in windows search? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableBing', $DisableBing)
}
if($( Read-Host -Prompt "Disable tips & tricks on the lockscreen? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable tips & tricks on the lockscreen? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableLockscreenTips', $DisableLockscreenTips)
}
if($( Read-Host -Prompt "Disable tips, tricks and suggestions in the startmenu and settings, and ads in windows explorer? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable tips, tricks and suggestions in the startmenu and settings, and ads in windows explorer? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableSuggestions', $DisableSuggestions)
}
if($( Read-Host -Prompt "Do you want to hide any icons from the taskbar? (y/n)" ) -eq 'y')
{
if($( Read-Host -Prompt "Hide the chat (meet now) icon on the taskbar? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Do you want to hide any icons from the taskbar? (y/n)" ) -eq 'y') {
if ($( Read-Host -Prompt "Hide the chat (meet now) icon on the taskbar? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableChat', $DisableChat)
}
if($( Read-Host -Prompt "Hide the widget (news and interests) icon on the taskbar? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Hide the widget (news and interests) icon on the taskbar? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableWidgets', $DisableWidgets)
}
}
if($( Read-Host -Prompt "Do you want to hide any folders from the windows explorer sidepanel? (y/n)" ) -eq 'y')
{
if($( Read-Host -Prompt "Hide the onedrive folder in windows explorer? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Do you want to hide any folders from the windows explorer sidepanel? (y/n)" ) -eq 'y') {
if ($( Read-Host -Prompt "Hide the onedrive folder in windows explorer? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableOnedrive', $DisableOnedrive)
}
if($( Read-Host -Prompt "Hide the 3D objects folder in windows explorer? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Hide the 3D objects folder in windows explorer? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('Disable3dObjects', $Disable3dObjects)
}
if($( Read-Host -Prompt "Hide the music folder in windows explorer? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Hide the music folder in windows explorer? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableMusic', $DisableMusic)
}
}
if($( Read-Host -Prompt "Do you want to disable any context menu options? (y/n)" ) -eq 'y')
{
if($( Read-Host -Prompt "Disable the 'Include in library' option in the context menu? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Do you want to disable any context menu options? (y/n)" ) -eq 'y') {
if ($( Read-Host -Prompt "Disable the 'Include in library' option in the context menu? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableIncludeInLibrary', $DisableIncludeInLibrary)
}
if($( Read-Host -Prompt "Disable the 'Give access to' option in the context menu? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable the 'Give access to' option in the context menu? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableGiveAccessTo', $DisableGiveAccessTo)
}
if($( Read-Host -Prompt "Disable the 'Share' option in the context menu? (y/n)" ) -eq 'y')
{
if ($( Read-Host -Prompt "Disable the 'Share' option in the context menu? (y/n)" ) -eq 'y') {
$PSBoundParameters.Add('DisableShare', $DisableShare)
}
}
@@ -319,75 +293,58 @@ if((-NOT $PSBoundParameters.Count) -or $RunDefaults -or $RunWin11Defaults -or ((
}
}
}
else
{
Clear
else {
Clear-Host
Write-Output "-------------------------------------------------------------------------------------------"
Write-Output " Win10Debloat Script - Custom Configuration"
Write-Output "-------------------------------------------------------------------------------------------"
}
# Execute all selected/provided parameters
switch ($PSBoundParameters.Keys)
{
'RemoveApps'
{
switch ($PSBoundParameters.Keys) {
'RemoveApps' {
RemoveApps
}
'DisableTelemetry'
{
'DisableTelemetry' {
RegImport "> Disabling telemetry, diagnostic data and targeted ads..." $PSScriptRoot\Regfiles\Disable_Telemetry.reg
}
'DisableBingSearches'
{
'DisableBingSearches' {
RegImport "> Disabling bing & cortana in windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Cortana_In_Search.reg
}
'DisableBing'
{
'DisableBing' {
RegImport "> Disabling bing & cortana in windows search..." $PSScriptRoot\Regfiles\Disable_Bing_Cortana_In_Search.reg
}
'DisableLockscreenTips'
{
'DisableLockscreenTips' {
RegImport "> Disabling tips & tricks on the lockscreen..." $PSScriptRoot\Regfiles\Disable_Lockscreen_Tips.reg
}
'DisableWindowsSuggestions'
{
'DisableWindowsSuggestions' {
RegImport "> Disabling tips, tricks and suggestions in the startmenu and settings, and ads in windows explorer..." $PSScriptRoot\Regfiles\Disable_Windows_Suggestions.reg
}
'DisableSuggestions'
{
'DisableSuggestions' {
RegImport "> Disabling tips, tricks and suggestions in the startmenu and settings, and ads in windows explorer..." $PSScriptRoot\Regfiles\Disable_Windows_Suggestions.reg
}
'DisableChat'
{
'DisableChat' {
RegImport "> Hiding the chat icon on the taskbar..." $PSScriptRoot\Regfiles\Disable_Chat_Taskbar.reg
}
'DisableWidgets'
{
'DisableWidgets' {
RegImport "> Hiding the widget icon on the taskbar..." $PSScriptRoot\Regfiles\Disable_Widgets_Taskbar.reg
}
'DisableOnedrive'
{
'DisableOnedrive' {
RegImport "> Hiding the onedrive folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_Onedrive_Folder.reg
}
'Disable3dObjects'
{
'Disable3dObjects' {
RegImport "> Hiding the 3D objects folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_3D_Objects_Folder.reg
}
'DisableMusic'
{
'DisableMusic' {
RegImport "> Hiding the music folder in windows explorer..." $PSScriptRoot\Regfiles\Hide_Music_folder.reg
}
'DisableIncludeInLibrary'
{
'DisableIncludeInLibrary' {
RegImport "> Disabling 'Include in library' in the context menu..." $PSScriptRoot\Regfiles\Disable_Include_in_library_from_context_menu.reg
}
'DisableGiveAccessTo'
{
'DisableGiveAccessTo' {
RegImport "> Disabling 'Give access to' in the context menu..." $PSScriptRoot\Regfiles\Disable_Give_access_to_context_menu.reg
}
'DisableShare'
{
'DisableShare' {
RegImport "> Disabling 'Share' in the context menu..." $PSScriptRoot\Regfiles\Disable_Share_from_context_menu.reg
}
}