jriver-exclusions.ps1 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <#
  2. .SYNOPSIS
  3. Adds JRiver Media Center folders, executables & processes to Windows Defender exclusions.
  4. .DESCRIPTION
  5. powershell -ExecutionPolicy Bypass -File .\jriver-exclusions.ps1
  6. #>
  7. # JRiver Media Center version to exclude
  8. $Version = 34
  9. function Add-ItemExclusion {
  10. param(
  11. [string]$Item,
  12. [ValidateSet('Path','Process')]$Type
  13. )
  14. try {
  15. if ($Type -eq 'Path') {
  16. Add-MpPreference -ExclusionPath $Item -ErrorAction Stop
  17. } else {
  18. Add-MpPreference -ExclusionProcess $Item -ErrorAction Stop
  19. }
  20. Write-Host "Added ${Type}: ${Item}"
  21. }
  22. catch {
  23. Write-Warning "Skipped/failed ${Type}: ${Item} - $_"
  24. }
  25. }
  26. # Build base dir & lists
  27. $exeDir = "C:\Program Files\J River\Media Center $Version"
  28. Write-Host "Configuring JRiver Media Center version $Version"
  29. $folders = @(
  30. 'C:\Program Files\J River',
  31. $exeDir,
  32. "$Env:APPDATA\J River",
  33. "$Env:APPDATA\J River\Media Center $Version"
  34. )
  35. $executables = @(
  36. "$exeDir\Media Editor.exe",
  37. "$exeDir\PackageInstaller.exe",
  38. "$exeDir\JRCrashHandler.exe",
  39. "$exeDir\JRMediaUninstall.exe",
  40. "$exeDir\JRService.exe",
  41. "$exeDir\JRWeb.exe",
  42. "$exeDir\JRWorker.exe",
  43. "$exeDir\MC$Version.exe",
  44. "$exeDir\Media Center $Version.exe",
  45. "C:\Windows\System32\MC$Version.exe",
  46. "C:\Windows\SysWOW64\MC$Version.exe"
  47. )
  48. $processes = @(
  49. "Media Center $Version.exe",
  50. "MC$Version.exe",
  51. 'JRService.exe',
  52. 'JRWorker.exe'
  53. )
  54. # Add exclusions
  55. Write-Host "=== Adding folder exclusions ==="
  56. $folders | ForEach-Object { Add-ItemExclusion -Item $_ -Type Path }
  57. Write-Host "=== Adding file exclusions ==="
  58. $executables | ForEach-Object { Add-ItemExclusion -Item $_ -Type Path }
  59. Write-Host "=== Adding process exclusions ==="
  60. ($processes + ($executables | Split-Path -Leaf) | Sort-Object -Unique) |
  61. ForEach-Object { Add-ItemExclusion -Item $_ -Type Process }
  62. # Summary
  63. $pref = Get-MpPreference
  64. Write-Host ''
  65. Write-Host "=== Current Defender exclusion counts ==="
  66. Write-Host (" Paths : {0}" -f $pref.ExclusionPath.Count)
  67. Write-Host (" Processes: {0}" -f $pref.ExclusionProcess.Count)
  68. Write-Host ''