Scott Hanselman

PowerShell CMDLET Visual Studio 2005 Item Template

October 20, '06 Comments [7] Posted in PowerShell
Sponsored By

Jason Scheuerman from my company has created a PowerShell Cmdlet Visual Studio 2005 Template so you can create PowerShell Cmdlets using File|Add New Item.

In the screenshot at right, I've select File|Add New Item and entered get-thing.cs as the name of my new Cmdlet.

If you want to use this Item Template, drop this zip file into your C:\Documents and Settings\<YourUserNameHere>\My Documents\Visual Studio 2005\Templates\ItemTemplates.

Don't unzip it, just put the ZIP itself in that folder.

You can learn more about creating Cmdlets (they're different from PowerShell Scripts (PS1 files) in that they can integrate more tightly with the pipeline and they can use parameter binding) at MSDN.

There's more about the difference between Cmdlets and scripts in my interview with Jeffrey Snover at Hanselminutes.com.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Saturday, October 21, 2006 3:10:32 AM UTC
Scott,

Would you export your VS setting and make them available for download?

Thanks,
Stephen
Stephen
Monday, October 23, 2006 12:09:01 PM UTC
Scott: Yes, any chance that you can share your Font and Colors Visual Studio settings? :)
Monday, October 23, 2006 1:02:13 PM UTC
@ Stepehen, Diego:
The color scheme that Scott uses looks like, Brad Wilson's Dark Visual Studio.
http://www.agileprogrammer.com/dotnetguy/archive/2006/09/07/19030.aspx
I use at home and rocks :)
Monday, October 23, 2006 5:50:12 PM UTC
http://www.hanselman.com/blog/ChangingYourColorsInVisualStudioNETBlackVersusWhite.aspx
Monday, October 23, 2006 6:15:52 PM UTC
Beh, It was a snap to create a new cmdlet ;)

By the way, when I create a new Cmdlet from the template,
the resion inside the class is collapsed.

Is there a way to prevent the source code folding so that right after creating a new class, one would not have to unfold the source?

Thank you in advance.
Sung Kim
Tuesday, October 24, 2006 1:06:03 AM UTC
Thanks Scott!
Diego Barros
Tuesday, October 24, 2006 6:15:47 PM UTC
Sung: Solution is pretty simple.

1) Open the zip file
2) Extract the .cs template file in there
3) Remove the #region statement lines
4) Put the .cs file back in the zip
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.