From c88c5acfea8ebd396188356bd8ffaf941cda35de Mon Sep 17 00:00:00 2001 From: Dmitry Khrebin Date: Fri, 28 Aug 2026 14:53:06 +0100 Subject: [PATCH] Test-ExchAVExclusions: add the server name to the output files I want to see the server name in the results. Engineers often share only one of the output files, and when the data comes from several servers there is nothing in the file that says which server it belongs to. Stamp the computer name into the BadExclusions and Results/Debug file names and into the header line written inside them. --- Diagnostics/AVTester/Test-ExchAVExclusions.ps1 | 12 ++++++------ docs/Diagnostics/Test-ExchAVExclusions.md | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Diagnostics/AVTester/Test-ExchAVExclusions.ps1 b/Diagnostics/AVTester/Test-ExchAVExclusions.ps1 index 85002b0f01..978bdbae3f 100644 --- a/Diagnostics/AVTester/Test-ExchAVExclusions.ps1 +++ b/Diagnostics/AVTester/Test-ExchAVExclusions.ps1 @@ -46,10 +46,10 @@ Just update script version to latest one. .OUTPUTS Log file: -$PSScriptRoot\Test-ExchAvExclusions-#DataTime#.txt +$PSScriptRoot\Test-ExchAvExclusions-#ServerName#-#DataTime#.txt List of Scanned Folders: -$PSScriptRoot\BadExclusions-#DataTime#.txt +$PSScriptRoot\BadExclusions-#ServerName#-#DataTime#.txt .EXAMPLE .\Test-ExchAVExclusions.ps1 @@ -101,7 +101,7 @@ function Write-HostLog ($message) { } } -$LogFileName = "Test-ExchAvExclusions" +$LogFileName = "Test-ExchAvExclusions-$env:COMPUTERNAME" $StartDate = Get-Date $StartDateFormatted = ($StartDate).ToString("yyyyMMddhhmmss") $Script:DebugLogger = Get-NewLoggerInstance -LogName "$LogFileName-Debug-$StartDateFormatted" -LogDirectory $PSScriptRoot -AppendDateTimeToFileName $false -ErrorAction SilentlyContinue @@ -114,7 +114,7 @@ SetWriteWarningAction ${Function:Write-HostLog} $BuildVersion = "" -Write-Host ("Test-ExchAVExclusions.ps1 script version $($BuildVersion)") -ForegroundColor Green +Write-Host ("Test-ExchAVExclusions.ps1 script version $($BuildVersion) on server $env:COMPUTERNAME") -ForegroundColor Green if ($ScriptUpdateOnly) { switch (Test-ScriptVersion -AutoUpdate -VersionsUrl "https://aka.ms/Test-ExchAVExclusions-VersionsURL" -Confirm:$false) { @@ -605,9 +605,9 @@ foreach ($extension in $extensionsList) { #Delete Random Folder Remove-Item $randomFolder -Confirm:$false -Force -Recurse -$OutputPath = Join-Path $PSScriptRoot BadExclusions-$StartDateFormatted.txt +$OutputPath = Join-Path $PSScriptRoot "BadExclusions-$env:COMPUTERNAME-$StartDateFormatted.txt" "###########################################################################################" | Out-File $OutputPath -"Exclusions analysis at $((Get-Date).ToString())" | Out-File $OutputPath -Append +"Exclusions analysis on server $env:COMPUTERNAME at $((Get-Date).ToString())" | Out-File $OutputPath -Append "###########################################################################################" | Out-File $OutputPath -Append # Report what we found diff --git a/docs/Diagnostics/Test-ExchAVExclusions.md b/docs/Diagnostics/Test-ExchAVExclusions.md index b1ab97d1c5..d7cb210dda 100644 --- a/docs/Diagnostics/Test-ExchAVExclusions.md +++ b/docs/Diagnostics/Test-ExchAVExclusions.md @@ -61,7 +61,7 @@ ScriptUpdateOnly | Just update script version to latest one. ## Outputs Log file: -$PSScriptRoot\Test-ExchAvExclusions-#DateTime#.txt +$PSScriptRoot\Test-ExchAvExclusions-#ServerName#-#DateTime#.txt List of Folders, extensions Scanned by AV and List of Non-Default Processes: -$PSScriptRoot\BadExclusions-#DateTime#.txt +$PSScriptRoot\BadExclusions-#ServerName#-#DateTime#.txt