diff --git a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WindowsDefenderConfigurator.java b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WindowsDefenderConfigurator.java index bc105459999..6806a742669 100644 --- a/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WindowsDefenderConfigurator.java +++ b/bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/internal/WindowsDefenderConfigurator.java @@ -340,16 +340,12 @@ public static String createAddExclusionsPowershellCommand(String extraSeparator) // https://learn.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps // https://learn.microsoft.com/en-us/powershell/module/defender/get-mppreference?view=windowsserver2019-ps // - // For .NET's stream API called LINQ see: - // https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable - String excludedPaths = paths.stream().map(Path::toString).map(p -> '"' + p + '"') + // For detailed explanations about how to add new exclusions see: + // https://learn.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps + + String excludedPaths = paths.stream().map(Path::toString).map(p -> "\"" + p + "\"") .collect(Collectors.joining(',' + extraSeparator)); - final String exclusionType = "ExclusionProcess"; //$NON-NLS-1$ - return String.join(';' + extraSeparator, "$exclusions=@(" + extraSeparator + excludedPaths + ')', //$NON-NLS-1$ - "$existingExclusions=[Collections.Generic.HashSet[String]](Get-MpPreference)." + exclusionType, //$NON-NLS-1$ - "if($existingExclusions -eq $null) { $existingExclusions = New-Object Collections.Generic.HashSet[String] }", //$NON-NLS-1$ - "$exclusionsToAdd=[Linq.Enumerable]::ToArray([Linq.Enumerable]::Where($exclusions,[Func[object,bool]]{param($ex)!$existingExclusions.Contains($ex)}))", //$NON-NLS-1$ - "if($exclusionsToAdd.Length -gt 0){ Add-MpPreference -" + exclusionType + " $exclusionsToAdd }"); //$NON-NLS-1$ //$NON-NLS-2$ + return "Add-MpPreference -ExclusionProcess " + extraSeparator + excludedPaths; //$NON-NLS-1$ } private static void excludeDirectoryFromScanning(IProgressMonitor monitor) throws IOException {