The Multifunctioning DBA

Nov 30 2012   5:07PM GMT

PowerShell Versions

Colin Smith Colin Smith Profile: Colin Smith


I ran into a version issue the other day. I have a script that uses import-csv with the -delimiter parameter that was introduced with PowerShell version 2.0. I attempted to run the script on a machine that was running Powershell version 1. This is an issue because the -delimiter parameter does not exist. This is an issue because the file I was reading in was not delimited by comma. So be careful and you might want to put a version check block in your scripts. Something like this.

$host.version.major -gt 1

If that is true then I would have been good to go. If that returns false, then I would be able to output an error that would have made troubleshooting the issue much easier and faster.

Hope that will help save you some headache.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: