Skip to content

Commit 56975e2

Browse files
IamLRBAHannesWell
andcommitted
Improved Windows Defender Exclusion Script Exclusion Script With Native PowerShell
- Changed Quoting style: Updated to use double quotes (safe for Windows paths) - Changed Formatting: From Simple comma joining to Additional separator for better formatting (extraSeparator) Co-authored-by: Hannes Wellmann <[email protected]> - Changed Script Structure: From originally Createing a PowerShell variable first to directly passing the array for compactness Co-authored-by: Hannes Wellmann <[email protected]>
1 parent 579ab29 commit 56975e2

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WindowsDefenderConfigurator.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,12 @@ public static String createAddExclusionsPowershellCommand(String extraSeparator)
340340
// https://learn.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps
341341
// https://learn.microsoft.com/en-us/powershell/module/defender/get-mppreference?view=windowsserver2019-ps
342342
//
343-
// For .NET's stream API called LINQ see:
344-
// https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable
345-
String excludedPaths = paths.stream().map(Path::toString).map(p -> "'" + p.replace("'", "''") + "'")
346-
.collect(Collectors.joining(','));
347-
return String.join(";",
348-
"$pathsToExclude = @(" + excludedPaths + ")",
349-
"Add-MpPreference -ExclusionProcess $pathsToExclude"
343+
// For detailed explanations about how to add new exclusions see:
344+
// https://learn.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps
345+
346+
String excludedPaths = paths.stream().map(Path::toString).map(p -> "\"" + p + "\"")
347+
.collect(Collectors.joining(',' + extraSeparator));
348+
return "Add-MpPreference -ExclusionProcess " + extraSeparator + excludedPaths; //$NON-NLS-1$
350349
);
351350
}
352351

0 commit comments

Comments
 (0)