W2KSG: Log Properties

Having seen how to view the log properties lets see how we can change them. One possibility is with WMI.  Lets start by viewing the event logs

Get-WmiObject -Class Win32_NTEventLogFile

one thing to note is that the property with the log file name is LogFileName rather than name

Listing 12.4

$applog = Get-WmiObject -Class Win32_NTEventLogFile -Filter "LogFileName = ‘Application’"

$applog.MaxFileSize = 26214400

$applog.psbase.Put()

Use get-wmiobject to access the log file. Set the maximum file size and use .psbase.put() to write back the change.  If you need to configure the size on a number of computers – create a csv file with the computer names then use

Import-csv | foreach{

$applog = Get-WmiObject -computername $_.Computer -Class Win32_NTEventLogFile -Filter "LogFileName = ‘Application’"

$applog.MaxFileSize = 26214400

$applog.psbase.Put()

}

 


Share this post :

 

Technorati Tags: ,,

 

 

About these ads
This entry was posted in PowerShell and WMI. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s