|
 Monday, February 25, 2008

Creating .NET Event Sources with PowerShell

I use Enterprise Library for Logging and I use different event sources for each app. I've noticed that creating event sources is kind of a pain sometimes. Either you have to write an app that does it for you, or you have to write some logic in your code that checks for the event source. Either way, I think that's too bloated for in-house software. Now for software that has to be deployed, then ok, no problem I see the use. But we're talking bout non-released code here. Code that is used on an internal site or externally facing site.

Or you can use PowerShell, simple as pie. :)

This one liner will check for the Event Source and if it does not exist, it will create it for you. Real easy. Gotta love PowerShell.

 

if (![System.Diagnostics.EventLog]::SourceExists("MySourceName")) { [System.Diagnostics.EventLog]::CreateEventSource("MySourceName", "Application") }

Now if we write an event to the event log, it will show up because the source now exists. :)

You HAVE TO love one liners that can replace entire applications. :) Albeit, not a big app, but an app, none the less.

#    Comments [0] |
 Thursday, February 21, 2008

Notepad? THE PowerShell IDE? Please, Save Me - Give Me Some IntelliSense

As of lately I've been tasked with more and more work with process automation. As usual, automation is usually found to be best suited for a scripting language and therefore I've been working with PowerShell a lot lately.

I'll admit - I have a problem with scripting languages the IDE's for Scripting Languages. What's the problem? The problem is that the IDE is usually Notepad. Don't get me wrong, I LOVE Notepad, so much that I use Notepad++ as my primary text editor. Adding it to the context menu has been one of the productivity boosters in my day to day work.

The real issue comes down to productivity. I don't write a .NET Enterprise app in Notepad, I use Visual Studio. Could I? Yes. I don't write a Professional Letter in Notepad, I do it in Word. Could I write it in Notepad? Yes. This list could go on and on. I could use MS Paint to create a nice 3D Image, but I wont. But why? Simple... its not productive to. Its not productive to write letters, enterprise applications, or create a billion dollar proposal in Notepad.

Millions of dollars have been put into productivity tools. The industry has put a bounty on productivity so high that entire companies are based around developer productivity. Tools and libraries such as ReSharper, DevExpress, Telerik, Infragistics, etc. help forge the way for developers to increase productivity in their day to day work. In this instance I'm talking about Windows development, there are MANY other companies that create productivity tools for many different industries, such as - graphic design, engineering, medial, etc. The point here is that time is money.

Tools, are exactly that - tools. We've come from the stone age where a wheel was an innovational tool to help move items easier. So please, this is 2008 , and in computer years that puts Notepad into the stone age. So, please don't code in Notepad if you don't have to. Using Notepad as a tool to edit files on the fly is priceless, but using the tool as a primary editor, is, well... ludicrous and crazy. There are many IDE's for almost any environment out there. As new languages are developed, new IDE's soon follow. Unfortunately, one of the worst parts about being bleeding-edge/an-early-adopter and using a new language is waiting for the tool support. Look at VS 2008, the third party companies couldn't even keep up with VS2008 release date. When PowerShell came out, the only IDE was Notepad. Unfortunately, most IT folks still seem to use Notepad for most of there PowerShell scripts. This drives me nuts. This is like driving across country when  you could fly. But hey, if you're into long, over drawn out processes, maybe driving across the country will suit you. I'll see you in NYC when you get there, I'll already have gone sight-seeing for 3 days prior to your arrival.

powerguibig This brings me back to PowerShell. There are many IDE's out there, some free, some not. The one I've seem to use on a regular basis is PowerGUI. Its simple, yet effective. Features include, IntellSense, built in help, debugging, watch window. You can also get more libraries from the downloads as well. For me, being able to debug into a script is worth its weight in gold. I don't know how many times back in ASP Classic I wrote:

Response.Write "In The If"

Man, I don't miss those days at all.

So let me say it again... if you're walking around in the stone age, its time to step out, get a IDE and start enjoying life again. Not reliving the "Response.Write" memoirs. :)

#    Comments [2] |
 Friday, February 08, 2008

Podcast for PowerShell - PowerScripting.net

In a previous post I wrote about staying up to date and how I do it. I included Blogs, Podcasts, Screencasts, etc.

This is one more Podcast to add to the list. The podcast covers all things PowerShell and I must say, its pretty good!

If there is one thing to add to your toolbelt this year, its PowerShell - even Jeffrey Snover agrees. I guess he doesn't count though ... he is one of the architects of it. :)

Apple ITunes Link For Podcast

#    Comments [0] |