September 25, 2021

USEFUL-IT

A blog for USEFUL-IT information

Eventlog Sizes

List Eventlogsizes

# ----------------------------------------------------------------------------- 
# Script: HTML_EventlogSize.ps1 
# Usage: HTML_EventlogSize.ps1 -path "c:\test\Eventlogsize.html" -Servers <server1>,<Server2> -eventlogs Application,System
# Author: ed wilson, msft 
# Adjustments: Wessel van Sandwijk, Useful-it.nl
# ----------------------------------------------------------------------------- 
# Date: 09/24/2013
# Keywords: Scripting Techniques, Web Pages and HTAs 
# comments: Get-Wmiobject, New-Object, Get-Date, Convertto-HTML, Invoke-Item 
# ----------------------------------------------------------------------------- 

Param( 
  [string]$path,
  [array]$servers,
  [array]$eventlogs
) 

Function Get-EventlogSize 
{ Param ([string[]]$servers) 
  Foreach ($s in $servers)  
    {  
		Foreach ($l in $eventlogs)
			{
				$os = Get-WmiObject -Class Win32_NTEventLogFile -cn $s -filter "LogFileName = '$l'"
        		$EventLogSize = $os.FileSize
        		$system=$os.CSname
				New-Object psobject -Property @{
        		FileSize = '{0:N0}' -f $eventLogSize;
				Eventlog=$l;
        		#computer=$s; 
        		System=$system;
				ReportDate =$(get-date)
				}
			}
    }
}

# Entry Point *** 

Get-EventlogSize -servers $servers  
ConvertTo-Html -As Table -body " 
  <h1>Server EventlogSizes Report</h1> 
  The following report was run on $(get-date)" >> $path
  Invoke-Item $path