PowerShell script to clear Event Log on remote machines in parallel (WinRM)

  1. Variable for a list of servers.
    #Server array
    $Serverlist = “WORK01”, “WORK02”, “WORK06”
  2.  The script will perform a check if the listed servers accept WinRM connections (used for the remoting).
    The ones which fail will be reported and excluded from the further action.


3.  Clear the full Windows Eventlog of the servers.


4. Force Restart of the Server

The event log deletion and restart will be performed in parallel for each available host.
After the Event Log is deleted, the script will wait the servers to reboot for 10min.

#Wait before the monitoring starts
Write-Host “Sleeping for 10 min.”
Start-Sleep -s 600

5. Check if Server is up. Report successful reboot or stuck server.



The reporting will be displayed in the console and also logged to a log file.

#Log file path

$logpath = “c:\temp\log_$(get-date -f yyyy-MM-dd).txt”

Log file example:



Leave a Reply

Your email address will not be published. Required fields are marked *