Skip to main content

Posts

Showing posts from February, 2015

Dumb Things You Need to Know to PowerShell

OK--so I'm not much of a blogger, but as I've started working with PowerShell to write a lot of scripts, I'd like to document some of the pains that it caused. The script parser reads from top to bottom, and if it hasn't read a function before it's called, it won't find the function. Yeah, I know. Just like all of the quirks that I'll list here, I'm sure they had a good reason for making it work like that, but it was painful learning it. So you'll just need to put all of your functions at the top, and the part of the script that runs first is at the end of the file. Passing multiple parameters to a function requires no parentheses, and no commas. Yeah, so when you call a function that has more than one parameter, don't use parentheses, and delimit the parameters with spaces. foo param1 param2 parm3 Update PowerShell before you start coding. PowerShell is not updated by Windows Update, so you'll want to get the late