Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Doing More With Functions: Comment-Based Help

I just wanted to throw together a post highlighting how cool and easy it is to add help data to your own Functions and scripts. The help data gets added via comments. For functions the help data can go in three places: For scripts we just put it at the top of your script before you type the param() statement, or at the ...

Inserting new elements into XML files

The Goal: Insert nodes into a specific place in XML config files The Motivation: I had a coworker a while back working with App Fabric. He needed to insert a particular chunk of XML into a specific spot inside of the config file. This had to be done on a bunch of different machines, but the kicker was that the config files might look ...

Doing More With Functions: Taking Parameters on the Pipe

In an earlier post, I showed you how you could use the [parameter(mandatory)] attribute to force your parameters to behave  a bit more like you'd expect from other languages. We also have a bunch of other useful attributes we can use on our parameters to enable cool features. Pipelineing The pipe might feel pretty magical to you in ...

PowerShell for Programmers: The Magic Switch!

Welcome back everyone, I'm trying out GitHub Gist for my code blocks this week. It lets you click and download them, as well as making them easy to edit. The downside is that I can't use my usual dark themed syntax highlighting. Let me know in the comments if you like gist or the old method better :) Switch statements in PowerShell are ...

PowerShell For Programmers: Strings, Quotes and Quirks

Welcome back everyone! This will be a short, but important entry for the guide. The difference between quote characters is something I’m asked about all the time. It is important to understand in PowerShell, but most of the time it probably won’t make a difference. TLDR: If you're just typing a value like "alg" then it doesn't ...