Functions/Public/Clear-Logs.ps1

function Clear-Logs {
    <#
    .SYNOPSIS
        Clear Windows Logs.
    .DESCRIPTION
        It clears all the logs (Event Viewer Logs) on your current computer. It uses the cmdlet "Get-WinEvent" to realize the cleaning.
        Some logs cannot be cleaned up because they are linked to the system or locked for other reasons.
    .EXAMPLE
        Clear-Logs
    .NOTES
        It must be run as admin to allow to delete logs.
    #>


    [CmdletBinding()]
    Param()
    
    # Run as admin
    Test-IsAdmin | Out-Null
    
    # Clear all the event logs on your computer.
    Write-Output "Clearing logs in progress... Please be patient!"
    Get-WinEvent -ListLog * -Force | Where-Object { Wevtutil.exe Clear-Log $_.LogName } | Out-Null
    Write-Output "Clearing logs done. Thanks for your patience."
}