Skip to content

Instantly share code, notes, and snippets.

@ndekross
ndekross / Optimize-WSLDefender.ps1
Created November 3, 2025 16:24
Excludes WSL2 process from Windows Defender anti-virus scanning and firewall rules
<#
.SYNOPSIS
Add/Remove Windows Defender exclusions tuned for WSL2 when projects live inside the Linux FS.
.USAGE
.\WSL2-DefenderExclusions.ps1 -Add
.\WSL2-DefenderExclusions.ps1 -Remove
#>
[CmdletBinding(SupportsShouldProcess=$true)]
param(
Windows Registry Editor Version 5.00
; Map extensions to 7-Zip ProgIDs (safe if already set)
[HKEY_CLASSES_ROOT\.zip] @="7-Zip.zip"
[HKEY_CLASSES_ROOT\.7z] @="7-Zip.7z"
[HKEY_CLASSES_ROOT\.rar] @="7-Zip.rar"
; --- ZIP: make extract the default verb, into <archive name>\ ---
[HKEY_CLASSES_ROOT\7-Zip.zip\shell]
@="extract"