Add your code snippets to PowerGUI

Want to add your PowerShell code snippets to PowerGUI Script Editor?


It is actually as easy as adding your xml .snippet file to the C:\Program Files\PowerGUI\snippets folder.

You can create a new file manually or use any Visual Studio-compatible snippet editor. I am using Snipp Dogg which is a free open source project on codeplex. So my instructions below are using this tool but anything else would do.

1. Run the tool as Administrator (or it would not be able to save to Program Files if you are on Vista or later.)

2. You can see and study any of the snippet files shipped with PowerGUI:


3. Click the New button to create a new snippet and then paste your code into the central pane – in my example I start with advanced function code from PowerShell v2 example:


4. If you want your snippet to have placeholders for certain variable names, parameters, and so on, you need to replace each of them with $some_kind_of_id$. In addition to that you can put $selected$ in front of the one you want to become selected once the snippet is inserted.

In my example, I am making the function name and the variable name these snippet parameters (in snippet lingo “literals”) and make the function name selected by default:


5. Fill out other snippet parameters in the right-hand pane (Snipp Dogg does not have powershell as a language option – shame on them – so either change it in the xml file later on or just leave it as csharp – PowerGUI does not check this field):


6. Expand the Literals collection and click New to add a new literal (remember: we need to specify two):


7. Fill out and save (by clicking OK) both functionname and param:



8. Save the snippet to the C:\Program Files\PowerGUI\snippets folder (requires admin rights in Vista and later):


9. Start PowerGUI Script Editor and insert the snippet:



That’s it! Happy scripting! 😉

Tags: , , ,


6 Responses to “Add your code snippets to PowerGUI”

  1. 1 Vadims Podāns September 4, 2009 at 6:25 pm

    Just one qustion: is there any workaround to save my own snippet to profile folder (not to PoweerGUI Program Files folder)? For example, add new path to snippets store?

  2. 2 Dmitry Sotnikov September 5, 2009 at 8:01 pm

    Unfortunately we don’t have this feature right now. If you need it – please post the request to the forum at

  3. 4 Vadims Podāns September 6, 2009 at 6:30 am

    > 1. Run the tool as Administrator (or it would not be able to save to Program Files if you are on Vista or later.)

    this is true not only for Vista and later. In Windows XP/Windows Server 2003 we need adminitrators rights too to write to Program Files folder.

  1. 1 PowerShell Script Templates « Dmitry’s PowerBlog: PowerShell and beyond Trackback on September 4, 2009 at 10:01 am
  2. 2 Snipp Dog – Un éditeur de snippet Trackback on March 9, 2011 at 10:50 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

My Recent Tweets


The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

June 2009

%d bloggers like this: