Nov 30 2012 5:07PM GMT
Posted by: Colin Smith
Database
PowerShell Versions
Posted by: 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.




