@@ -335,21 +335,11 @@ private static boolean isWindowsDefenderActive(IProgressMonitor monitor) throws
335335
336336 public static String createAddExclusionsPowershellCommand (String extraSeparator ) {
337337 List <Path > paths = getExecutablePath ();
338- // For detailed explanations about how to read existing exclusions and how to
339- // add new ones see:
338+ // For detailed explanations about how to add new exclusions see:
340339 // https://learn.microsoft.com/en-us/powershell/module/defender/add-mppreference?view=windowsserver2019-ps
341- // https://learn.microsoft.com/en-us/powershell/module/defender/get-mppreference?view=windowsserver2019-ps
342- //
343- // For .NET's stream API called LINQ see:
344- // https://learn.microsoft.com/en-us/dotnet/api/system.linq.enumerable
345340 String excludedPaths = paths .stream ().map (Path ::toString ).map (p -> '"' + p + '"' )
346341 .collect (Collectors .joining (',' + extraSeparator ));
347- final String exclusionType = "ExclusionProcess" ; //$NON-NLS-1$
348- return String .join (';' + extraSeparator , "$exclusions=@(" + extraSeparator + excludedPaths + ')' , //$NON-NLS-1$
349- "$existingExclusions=[Collections.Generic.HashSet[String]](Get-MpPreference)." + exclusionType , //$NON-NLS-1$
350- "if($existingExclusions -eq $null) { $existingExclusions = New-Object Collections.Generic.HashSet[String] }" , //$NON-NLS-1$
351- "$exclusionsToAdd=[Linq.Enumerable]::ToArray([Linq.Enumerable]::Where($exclusions,[Func[object,bool]]{param($ex)!$existingExclusions.Contains($ex)}))" , //$NON-NLS-1$
352- "if($exclusionsToAdd.Length -gt 0){ Add-MpPreference -" + exclusionType + " $exclusionsToAdd }" ); //$NON-NLS-1$ //$NON-NLS-2$
342+ return "Add-MpPreference -ExclusionProcess " + extraSeparator + excludedPaths ; //$NON-NLS-1$
353343 }
354344
355345 private static void excludeDirectoryFromScanning (IProgressMonitor monitor ) throws IOException {
0 commit comments