Google

Welcome to Carpe Diem: Flaphead@Home Sign in | Join | Help

Carpe Diem: Flaphead.com

Seize the Day

News


  • Add to Technorati Favorites <script type="text/javascript" src="http://technorati.com/embed/3ni3q36ikc.js"> </script>
    This information is provided "AS IS" with no warranties, and confers no rights. Also some of the information contains my views and thoughts.
    <script src="http://widgets.technorati.com/t.js" type="text/javascript" charset="UTF-8"></script>

    Add Me! - Search Engine Optimization

    I heart FeedBurner

PowerShell and EventLogs

So I have been "play" with PowerShell again today, and I have trying to work out how to write an Event to the Eventlog.

Richard gave me some code to do it with vbs, but I found this while surfing (it has taken an age to find!) http://winpowershell.blogspot.com/2006_07_01_archive.html

Anyway, not I have found it the world is my oyster!  So my latest script is for BlackBerry.  It runs BBSrptest and parses the result.  If it fails it will generate an Error in the Application Eventlog and send an email about the failure.  If it okay, it just generates an Information event.

Code is attached, but here is the eventlog bit.  It is surprising how easy it is to use!

##########################################################################################
#Set variable to log stuff to the application event log
#
#Valid values for [System.Diagnostics.EventLogEntryType]
#Error; Warning; Information; SuccessAudit; FailureAudit
##########################################################################################
$evt=new-object System.Diagnostics.EventLog("Application")
$evt.Source="My BlackBerrry"
$infoevent=[System.Diagnostics.EventLogEntryType]::Information

...

$evt.WriteEntry($strOutput,$infoevent,1)

Posted: 12 November 2007 22:59 by Paul Flaherty
Attachment(s): Test-BlackBerry.ps1

Comments

subject: exchange said:

Inside the Exchange Server Profile Analyzer Will replication in Exchange Server 2007 SP1 woo IT? Advanced

# November 17, 2007 18:19
New Comments to this post are disabled