-
-
Save ykfq/8af8c733fd164c8949790c78771fd0f8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Save-AllExchangeLogs.ps1 | |
$timeString = (Get-Date).ToString("yyyyMMddHHmm") | |
$machineName = [Environment]::MachineName | |
$targetFolder = "$home\desktop\ExchangeLogs-$machineName-$timeString" | |
md $targetFolder | Out-Null | |
"Saving $targetFolder\Application.evtx..." | |
wevtutil epl Application "$targetFolder\Application.evtx" | |
"Saving $targetFolder\System.evtx..." | |
wevtutil epl System "$targetFolder\System.evtx" | |
$exchangeLogs = wevtutil el | WHERE { $_.Contains("Exchange") } | |
foreach ($log in $exchangeLogs) | |
{ | |
$targetFile = Join-Path $targetFolder "$log.evtx" | |
"Saving $targetFile..." | |
$dir = [IO.Path]::GetDirectoryName($targetFile) | |
if (!(Test-Path $dir)) { New-Item -ItemType Directory $dir | Out-Null } | |
wevtutil epl $log $targetFile | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment