tags:

views:

88

answers:

2

I'm working on creating a script template to jump start the creation of new powershell scripts.

A quick list of some of the things I'm considering:

  • params block
  • usage function
  • main function
  • support for -verbose, -debug etc

Does anyone have something like this already, that they could share?

+1  A: 

I recommend PowerGUI's editor found here

It has great intellisense code completion and a super 'snippet' feature which will essentially give you blocks of code you can customize. There's even a vbsnippet option which enables you to enter the equivalent code in vbscript which it will translate for you.

Should take you no time at all to build a quick template of the usual things you want in your scripts so that you're not faced with the horror of a blank page.

Yanagi
+1  A: 

You should use comment based help instead of usage functions. Comment based help will allow you to work with the build in help system of PowerShell. It isn't hard to write and you don't even need to use all the sections.

Here is the help on it, with some examples: http://technet.microsoft.com/en-us/library/dd819489.aspx

You do have to make sure the categories are spelled correctly, otherwise the whole help on your function won't show up and you won't get an error message.

JasonMArcher