CTP3 – Write-EventLog

Last of the new event log cmdlets is Write-EventLog.  I showed how to write to the event log here http://richardsiddaway.spaces.live.com/blog/cns!43CFA46A74CF3E96!275.entry.  This is still valid for PowerShell v1 or v2.  In v2 we can make life a bit simpler by using Write-EventLog.  Like the other EventLog cmdlets it only works with the classic event logs and it has a –computername parameter so you can write to logs on remote machines.

To write an entry into the log:

Write-EventLog -LogName Scripts -Source PSscripts -Message "Test from write-eventlog"  `

-EntryType Information -EventId 1111

We need to give the log name and a source.  If you aren’t sure about the sources available for a log use the script in the previous post to discover them.  A message and entry type must be given and an eventid (can be arbitrary in your own log).

The entry can be viewed with Get-EventLog

That finishes our look at event logs in CTP3. Next time we will start looking at another aspect of CTP3.

 

Technorati Tags: ,,

About these ads
This entry was posted in PowerShell V2. 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