Download and run Microsoft Security Scanner (MSERT)

First download:
powershell -Command "& {Start-BitsTransfer -Source "http://definitionupdates.microsoft.com/download/definitionupdates/safetyscanner/amd64/msert.exe" -Destination "C:\users\public\downloads\msert\msert.exe"}"

Run:
C:\Users\Public\Downloads\msert\msert.exe /Q /H

Script to parse log and create Event:
# Requires that New-EventLog -LogName -Source "MSERT" is run on the system first

$msertfile = "C:\Windows\debug\msert.log"
$msertmessage = Get-Content $msertfile
$searchtext = "No infection found"
$source = "MSERT"

if ($msertmessage | Select-String $searchtext -quiet)
{ write-Host $searchtext
Write-EventLog -LogName Application -Source $Source -EventId 0 -Message "$msertmessage" -EntryType Information }
else
{ Write-EventLog -LogName Application -Source $Source -EventID 1 -Message "$msertmessage" -EntryType Error }

Move logs:
cmd /c move /y "C:\Windows\debug\msert.log" "C:\Users\Public\Downloads\msert\msert_%date:~-7,2%.log"

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.