Sunday, October 24, 2010

Using Write-EventLog…

I was trying to use the Write-EventLog cmdlet and was noticing additional annoying text being added to the messages.  For example:

PS> write-eventlog -logname "Windows PowerShell" -source PowerShell –event 999 -message "Hello"

Looking at the resulting event, I would see this added:

"The description for Event ID 999 from source PowerShell cannot be
found. Either the component that raises this event is not installed on
your local computer or the installation is corrupted. You can install
or repair the component on the local computer...."

I didn’t want this extra text, and couldn’t seem to figure out the problem, then came across something that Stefan Stranger did HERE:

if(![System.Diagnostics.EventLog]::SourceExists($source))
{
[System.Diagnostics.EventLog]::CreateEventSource($source,'Application')
}

The trick to getting rid of this extra text was to make my own custom source for my events.  Now, the extra text is gone.  I just made up “PowerShell_script”, and used that in my script.

Friday, October 1, 2010

Microsoft MVP for another year…

Today is my re-award date, and I just received a pleasant surprise.

I have been awarded a Microsoft MVP award (PowerShell of course!) for another year.

Looking back, I’ve eased up on blogging (and haven’t been able to tweet all that much), but I’ve been pretty active in other areas, and am looking to continue that for the foreseeable future.

Microsoft: Thanks for the recognition.