Wednesday, May 6, 2009

Oafish Doofishness and PowerShell-ishness

I'm such a doof.  I didn't realize that like KiXtart, PowerShell also supports inline string variable expansion.  Even more doofish than that, is the notion that anyone not familiar with scripting probably has no idea what last sentence really means.  Lots of aggressive syllables though.  Man!  It must be awesome!  Well, it's not.

So, what the ___ am I talking about?

Rather than having to join a string and a variable with duct tape:

$thing = "dog"
write-host "The cat was eaten by the "+$thing
> "The cat was eaten by the dog"

You can move the variable "inside" the string (within the matching quotes) and it works the same:

$thing = "dog"
write-host "The cat was eaten by the $thing"
> "The cat was eaten by the dog"

Ok, you can go back to sleep now.

No comments: