Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep only the main branch #183

Merged
merged 14 commits into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
⚠ **Warning**: this file is subject to changing without notice.

I would be happy to extend the collection of scripts.
If you want to send me a **PULL REQUEST**, send you PRs to the `develop` branch, select your `local branch (from)` and put into `develop`, i'll check your code, request changes if necessary or approve, and merge directly unless it's a "Draft PR".
If you want to send me a **PULL REQUEST**, send you PRs to the `main` branch, I'll check your code, request changes if necessary or approve, and merge directly unless it's a "Draft PR".

## 🖌 Coding Style

@@ -51,13 +51,16 @@ Follow at least the minimal required to help.
### Via HTTPS

```sh
git clone -b develop --filter=tree:0 https://github.com/LeDragoX/Win-Debloat-Tools.git
git clone --filter=tree:0 https://github.com/LeDragoX/Win-Debloat-Tools.git
```

### Or SSH
## 👾 Debugging with all modules

```sh
git clone -b develop --filter=tree:0 [email protected]:LeDragoX/Win-Debloat-Tools.git
On VSCode the modules seems to not load all the divergent variables and functions dynamically, to fix that, all modules should be imported manually:

```ps1
Get-Item .\src\lib\*.psm1 | Import-Module -PassThru -Force
Get-Item .\src\lib\**\*.psm1 | Import-Module -PassThru -Force
```

## 🔎 How to find specific Tweaks? (One method)
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ I need to change these files:

## 🚀 Download Latest Version

Code located in the `main` branch is considered stable, the `develop` branch contains the most recent features.
Code located in the `main` branch is considered bleeding-edge, but big features/reworks will be implemented in a separate branch.

> [!IMPORTANT]
> *Use on a fresh Windows install to notice the differences. Using an admin account is recommended to avoid any compatibility issues.*
@@ -42,22 +42,22 @@ Code located in the `main` branch is considered stable, the `develop` branch con
<th>Branch to Download</th>
<th>Version(s) Supported</th>
<th>Edition(s)</th>
<th>Architecture</th>
<th>PowerShell Version</th>
</tr>
</thead>
<tbody align="center">
<tr>
<td>
<h4><a href="https://github.com/LeDragoX/Win-Debloat-Tools/archive/main.zip">⬇️ Main</a></h4>(Stable)
<h4><a href="https://github.com/LeDragoX/Win-Debloat-Tools/archive/main.zip">⬇️ Main</a></h4>(Current)
</td>
<td rowspan="2">23H2 or Older</td>
<td rowspan="2">Home / Pro</td>
<td rowspan="2"><img width=20px src="src/assets/powershell-icon.png" style="vertical-align: bottom" /> v5.1+</td>
</tr>
<tr>
<td>
<h4><a href="https://github.com/LeDragoX/Win-Debloat-Tools/archive/develop.zip">⬇️ Develop</a></h4>(Newer)
<td rowspan="2">
x86/x64 ONLY<br>
ARM/ARM64 will break your installation (<a href="https://github.com/LeDragoX/Win-Debloat-Tools/issues/97">#97</a>)
</td>
<td rowspan="2"><img width=20px src="src/assets/powershell-icon.png" style="vertical-align: bottom" /> v5.1+</td>
</tr>
</tbody>
</table>
4 changes: 3 additions & 1 deletion WinDebloatTools.ps1
Original file line number Diff line number Diff line change
@@ -1544,7 +1544,9 @@ function Show-GUI() {

If ($InstallGitGnupgSshSetup.CheckState -eq "Checked") {
If (!($Script:UninstallSwitch)) {
Stop-Logging # Don't log any credential info after this point
Open-PowerShellFilesCollection -RelativeLocation "src\scripts\other-scripts" -Scripts @("Git-GnupgSshKeysSetup.ps1") -DoneTitle $DoneTitle -DoneMessage $DoneMessage
Start-Logging -File "$CurrentFileName-$(Get-Date -Format "yyyy-MM")"
} Else {
$AppsSelected.WingetApps.AddRange(@("Git.Git", "GnuPG.GnuPG")) # Installed before inside the script
}
@@ -1572,7 +1574,7 @@ function Show-GUI() {
}

If ($InstallJavaJdks.CheckState -eq "Checked") {
$AppsSelected.WingetApps.AddRange(@("EclipseAdoptium.Temurin.8", "EclipseAdoptium.Temurin.11", "EclipseAdoptium.Temurin.18"))
$AppsSelected.WingetApps.AddRange(@("EclipseAdoptium.Temurin.8.JDK", "EclipseAdoptium.Temurin.11.JDK", "EclipseAdoptium.Temurin.18.JDK"))
$InstallJavaJdks.CheckState = "Unchecked"
}

80 changes: 43 additions & 37 deletions src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1
Original file line number Diff line number Diff line change
@@ -20,49 +20,55 @@ function Remove-ItemPropertyVerified() {
}

Process {
If ((Get-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\").Property -ccontains $Name) {
Write-Status -Types "-", $TweakType -Status "Removing: `"$Path>$Name`""
ForEach ($DirectoryPath in $Path) {
If (Test-Path "$DirectoryPath") {
If ((Get-Item -Path "$DirectoryPath").Property -ccontains $Name) {
Write-Status -Types "-", $TweakType -Status "Removing: `"$DirectoryPath>$Name`""

If ($null -ne $Path) {
$ScriptBlock += " -Path "
ForEach ($PathParam in $Path) {
$ScriptBlock += "`"$PathParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}
If ($null -ne $DirectoryPath) {
$ScriptBlock += " -Path "
$ScriptBlock += "`"$DirectoryPath`", "
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}

If ($null -ne $Name) {
$ScriptBlock += " -Name "
ForEach ($NameParam in $Name) {
$ScriptBlock += "`"$NameParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}
If ($null -ne $Name) {
$ScriptBlock += " -Name "
ForEach ($NameParam in $Name) {
$ScriptBlock += "`"$NameParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}

If ($null -ne $Include) {
$ScriptBlock += " -Include "
ForEach ($IncludeParam in $Include) {
$ScriptBlock += "`"$IncludeParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}
If ($null -ne $Include) {
$ScriptBlock += " -Include "
ForEach ($IncludeParam in $Include) {
$ScriptBlock += "`"$IncludeParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}

If ($null -ne $Exclude) {
$ScriptBlock += " -Exclude "
ForEach ($ExcludeParam in $Exclude) {
$ScriptBlock += "`"$ExcludeParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}
If ($null -ne $Exclude) {
$ScriptBlock += " -Exclude "
ForEach ($ExcludeParam in $Exclude) {
$ScriptBlock += "`"$ExcludeParam`", "
}
$ScriptBlock = $ScriptBlock.TrimEnd(", ")
}

If ($null -ne $Force) {
$ScriptBlock += " -Force"
}
If ($null -ne $Force) {
$ScriptBlock += " -Force"
}

Write-Verbose "> $ScriptBlock"
Invoke-Expression "$ScriptBlock"
} Else {
Write-Status -Types "?", $TweakType -Status "The property `"$Path>$Name`" does not exist." -Warning
Write-Verbose "> $ScriptBlock"
Invoke-Expression "$ScriptBlock"
$ScriptBlock = "Remove-ItemProperty"
} Else {
Write-Status -Types "?", $TweakType -Status "The property `"$DirectoryPath>$Name`" does not exist." -Warning

}
} Else {
Write-Status -Types "?", $TweakType -Status "The path(s) `"$DirectoryPath`" to the property `"$Name`" couldn't be found." -Warning
}
}
}
}
43 changes: 7 additions & 36 deletions src/lib/ui/Get-CurrentResolution.psm1
Original file line number Diff line number Diff line change
@@ -5,45 +5,16 @@ function Get-CurrentResolution() {
[OutputType([System.Object[]])]
param ()

# Adapted from: https://www.reddit.com/r/PowerShell/comments/67no9x/comment/dgrry3b/?utm_source=share&utm_medium=web2x&context=3
$NumberOfScreens = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Where-Object { $_.Active -like "True" }).Active.Count
$ScreenWidth = $null
$ScreenHeight = $null
Add-Type -AssemblyName System.Windows.Forms

Write-Verbose "Num. of Monitors: $NumberOfScreens"
# Get the primary screen's working area, which takes DPI scaling into account
$PrimaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen
$WorkingArea = $PrimaryScreen.WorkingArea

If ($NumberOfScreens -eq 1) {
# Accepts Scaling/DPI
[System.Windows.Forms.SystemInformation]::VirtualScreen | ForEach-Object {
Write-Verbose "W: $($_.Width) | H: $($_.Height)"
$ScreenWidth = $WorkingArea.Width
$ScreenHeight = $WorkingArea.Height

If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.Width
$ScreenHeight = $_.Height
}
Write-Verbose "Primary Monitor: Width: $ScreenWidth, Height: $ScreenHeight (DPI Scaled)"

If (($_.Width) -and ($_.Width -le $ScreenWidth)) {
$ScreenWidth = $_.Width
$ScreenHeight = $_.Height
}
}
} Else {
# Doesn't accepts Scaling/DPI (rollback method)
Get-CimInstance -Class "Win32_VideoController" | ForEach-Object {
Write-Verbose "W: $($_.CurrentHorizontalResolution) | H: $($_.CurrentVerticalResolution)"

If (!$ScreenWidth -or !$ScreenHeight) {
$ScreenWidth = $_.CurrentHorizontalResolution
$ScreenHeight = $_.CurrentVerticalResolution
}

If (($_.CurrentHorizontalResolution) -and ($_.CurrentHorizontalResolution -le $ScreenWidth)) {
$ScreenWidth = $_.CurrentHorizontalResolution
$ScreenHeight = $_.CurrentVerticalResolution
}
}
}

Write-Verbose "Width: $ScreenWidth, Height: $ScreenHeight"
return $ScreenWidth, $ScreenHeight
}
8 changes: 0 additions & 8 deletions src/scripts/Optimize-WindowsFeaturesList.ps1
Original file line number Diff line number Diff line change
@@ -22,11 +22,6 @@ function Optimize-WindowsFeaturesList() {
"WorkFolders-Client" # Work Folders Client
)

$EnableFeatures = @(
"NetFx3" # NET Framework 3.5
"NetFx4Extended-ASPNET45" # NET Framework 4.x + ASPNET 4.x
)

Write-Title "Optional Features Tweaks"
Write-Section "Uninstall Optional Features from Windows"

@@ -36,9 +31,6 @@ function Optimize-WindowsFeaturesList() {
} Else {
Set-OptionalFeatureState -State 'Disabled' -OptionalFeatures $DisableFeatures
}

Write-Section "Install Optional Features from Windows"
Set-OptionalFeatureState -State 'Enabled' -OptionalFeatures $EnableFeatures
}

# List all Optional Features:
2 changes: 1 addition & 1 deletion src/scripts/Register-PersonalTweaksList.ps1
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ function Register-PersonalTweaksList() {
$TimeoutScreenPluggedIn = 10

$TimeoutStandByBattery = 15
$TimeoutStandByPluggedIn = 180
$TimeoutStandByPluggedIn = 30

$TimeoutDiskBattery = 20
$TimeoutDiskPluggedIn = 30
3 changes: 2 additions & 1 deletion src/scripts/Remove-BloatwareAppsList.ps1
Original file line number Diff line number Diff line change
@@ -54,8 +54,9 @@ function Remove-BloatwareAppsList() {

# Default Windows 11 apps
"Clipchamp.Clipchamp" # Clipchamp – Video Editor
"Microsoft.OutlookForWindows" # Microsoft Outlook
"MicrosoftTeams" # Microsoft Teams
"MicrosoftWindows.Client.WebExperience" # Taskbar Widgets
"MicrosoftTeams" # Microsoft Teams / Preview

# [DIY] Remove the # to Uninstall

17 changes: 9 additions & 8 deletions src/scripts/other-scripts/Git-GnupgSshKeysSetup.ps1
Original file line number Diff line number Diff line change
@@ -145,11 +145,11 @@ function Set-GPGKey() {
Write-Host "Before exporting your public and private keys, add manually an email." -ForegroundColor Cyan
Write-Host "Type: 1 (RSA and RSA) [ENTER]." -ForegroundColor Cyan
Write-Host "Type: 4096 [ENTER]." -ForegroundColor Cyan
Write-Host "Then: 0 (does not expire at all) [ENTER]." -ForegroundColor Cyan
Write-Host "Then: 0 (does not expire at all) or `"10y`" [ENTER]." -ForegroundColor Cyan
Write-Host "Then: y [ENTER]." -ForegroundColor Cyan
Write-Host "Then: $(git config --global user.name) [ENTER]." -ForegroundColor Cyan
Write-Host "Then: $(git config --global user.email) [ENTER]" -ForegroundColor Cyan
Write-Host "Then: Anything you want (e.g. git keys) [ENTER]." -ForegroundColor Cyan
Write-Host "Then: Anything you want (e.g. Git Keys) [ENTER]." -ForegroundColor Cyan
Write-Host "Then: O (Ok) [ENTER]." -ForegroundColor Cyan
Write-Host "Then: [your passphrase] [ENTER]." -ForegroundColor Cyan
Write-Host "Then: [your passphrase again] [ENTER]." -ForegroundColor Cyan
@@ -160,7 +160,7 @@ function Set-GPGKey() {
Write-Status -Types "@" -Status 'gpg --delete-keys $(git config --global user.name)'

Write-Host "Copying all files to $GnuPGPath"
Copy-Item -Path "$GnuPGGeneratePath/*" -Destination "$GnuPGPath/" -Recurse
Copy-Item -Path "$GnuPGGeneratePath/*" -Destination "$GnuPGPath/" -Recurse -Force
Remove-ItemVerified -Path "$GnuPGPath/*" -Exclude "*.gpg", "*.key", "*.pub", "*.rev" -Recurse
Remove-ItemVerified -Path "$GnuPGPath/trustdb.gpg"

@@ -169,12 +169,13 @@ function Set-GPGKey() {
gpg --output "$($GnuPGFileName)_secret.gpg" --armor --export-secret-key "$(git config --global user.email)"

# Get the exact Key ID from the system
$key_id = $((gpg --list-keys --keyid-format LONG).Split(" ")[5].Split("/")[1])
$KeyId = $((gpg --list-keys --keyid-format LONG).Split(" ")[5].Split("/")[1])
$CurrentGPGKey = $(git config --global user.signingkey)

If (!(($key_id -eq "") -or ($null -eq $key_id))) {
Write-Host "GPG Key id found: $key_id."
If (($KeyId -eq "") -or ($null -eq $KeyId) -or ($KeyId -ne $CurrentGPGKey)) {
Write-Host "GPG Key id found: $KeyId."
Write-Host "Registering the GPG Key ID to git user..."
git config --global user.signingkey "$key_id"
git config --global user.signingkey "$KeyId"
Write-Host "Your user.signingkey on git is: $(git config --global user.signingkey)"

Write-Host "Enabling commit.gpgsign on git..."
@@ -183,7 +184,7 @@ function Set-GPGKey() {
Write-Host "Copy and Paste the lines below on your`nGithub/Gitlab > Settings > SSH and GPG Keys > New GPG Key"
Get-Content -Path "$GnuPGPath/$($GnuPGFileName)_public.gpg" -Encoding UTF8
} Else {
Write-Host "Failed to retrieve your key_id: $key_id"
Write-Host "Failed to retrieve your key_id: $KeyId"
}

Write-Host "Importing your key on $GnuPGPath\$($GnuPGFileName)_public.gpg and $($GnuPGFileName)_secret.gpg"
5 changes: 1 addition & 4 deletions src/scripts/other-scripts/Install-ArchWSL.ps1
Original file line number Diff line number Diff line change
@@ -10,10 +10,7 @@ function Install-ArchWSL() {
If ($OSArch -like "x64") {
$CertOutput = Get-APIFile -URI "https://api.github.com/repos/yuk7/ArchWSL/releases/latest" -ObjectProperty "assets" -FileNameLike "ArchWSL-AppX_*_$OSArch.cer" -PropertyValue "browser_download_url" -OutputFile "ArchWSL.cer"
Write-Status -Types "+" -Status "Installing ArchWSL Certificate ($OSArch)..."
Import-Certificate -FilePath $CertOutput -CertStoreLocation Cert:\LocalMachine\Root | Out-Host
Write-Status -Types "?" -Status "The certificate needs to be installed manually, the cmdlet didn't work for some reason..." -Warning
Write-Status -Types "@" -Status "Steps: Install Certificate... (Next) > Select Local Machine (Next) > Next > Finish > OK" -Warning
Start-Process -FilePath "$CertOutput" -Wait
certutil.exe -addstore "Root" $CertOutput | Out-Host
$ArchWSLOutput = Get-APIFile -URI "https://api.github.com/repos/yuk7/ArchWSL/releases/latest" -ObjectProperty "assets" -FileNameLike "ArchWSL-AppX_*_$OSArch.appx" -PropertyValue "browser_download_url" -OutputFile "ArchWSL.appx"
Write-Status -Types "+" -Status "Installing ArchWSL ($OSArch)..."
Add-AppxPackage -Path $ArchWSLOutput
7 changes: 6 additions & 1 deletion src/utils/Individual-Tweaks.psm1
Original file line number Diff line number Diff line change
@@ -499,7 +499,12 @@ function Disable-WindowsSpotlight() {

function Enable-WindowsSpotlight() {
Write-Status -Types "*", "Privacy" -Status "Enabling Windows Spotlight Features..."
Set-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightFeatures" -Type DWord -Value 0
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "ConfigureWindowsSpotlight"
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "IncludeEnterpriseSpotlight"
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightFeatures"
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightOnActionCenter"
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightOnSettings"
Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightWindowsWelcomeExperience"
}

function Disable-XboxGameBarDVRandMode() {