Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This script will ask you to enter a folder path
- # DO NOT wrap the folder path in quotes
- Write-Host
- Write-Host "Add or Remove a folder in Windows Defender's exclusion list"
- Write-Host
- $FolderPath = Read-Host "Enter a folder path without quotes"
- $ShowExclusions = {
- Invoke-Expression "Clear-Host; Write-Host"
- Write-Host "Current Excluded Folders"; Write-Host
- Get-MpPreference | Select-Object -Expand ExclusionPath
- Write-Host; Read-Host "Press Enter to exit"
- Invoke-Expression "Clear-Host; Write-Host"
- }
- Invoke-Expression "Clear-Host; Write-Host"
- Write-Host "Add or Remove: $FolderPath"
- Write-Host
- Write-Host "[1] Add"
- Write-Host "[2] Remove"
- Write-Host "[3] Exit"
- Write-Host
- $myChoice = [int](Read-Host "Enter a number")
- If ($myChoice -eq "1") {
- Add-MpPreference -ExclusionPath $FolderPath
- &$ShowExclusions
- }
- ElseIf ($myChoice -eq "2") {
- Remove-MpPreference -ExclusionPath $FolderPath
- &$ShowExclusions
- }
- ElseIf ($myChoice -eq "3") { Invoke-Expression "Clear-Host; Write-Host" }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement