Public/Clear-Logs.ps1

function Clear-Logs
{
    <#
        .SYNOPSIS
        Clear all Windows event logs
        .DESCRIPTION
        Clears all Windows event logs (requires elevated privileges)
        .NOTES
        Author: Marc Bouchard - marc@subnet192.com
        .EXAMPLE
        Clear-Logs
    #>
    
    
    <#
     -----------------------------------------------------------[Execution]------------------------------------------------------------
    #>

    
    # This command needs to run with elevated privileges. If the powershell session is not running "as Administrator", a new window will open to execute the command.
    if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
    {
        Start-Process powershell.exe -Verb RunAs -ArgumentList '-Command &{`
        Write-Host "Clearing all Windows event logs" -ForegroundColor Green`
        wevtutil el | foreach { wevtutil cl "$_" }`
        }'

    }
    else
    {
        Write-Host "Clearing all Windows event logs" -ForegroundColor Green
        wevtutil el | foreach { wevtutil cl "$_" }
    }
    
} #END function