I have a lot of Powershell scripts that I run in different environments.
Now, I have lately started to use functionality that is available in v3 and up. However, when running these scripts where only v2 is available will make them break bad.
Of course, I could go through all scripts and add a check of get-host to see what version is running and then ending the script if it is not compatible. However, I'd rather like to have a way to automatically parse the script and then get a message on which line(s) that is not supported in v2 so that I more easily can go through the scripts and fix this. Testrunning them all is far to timeconsuming even though it will give me the same result (more or less), breaking with errors on the offending lines.
So, is there a way to check scripts for functionality that is not supported in >v2 other than just running the scripts and see if they break?
Now, I have lately started to use functionality that is available in v3 and up. However, when running these scripts where only v2 is available will make them break bad.
Of course, I could go through all scripts and add a check of get-host to see what version is running and then ending the script if it is not compatible. However, I'd rather like to have a way to automatically parse the script and then get a message on which line(s) that is not supported in v2 so that I more easily can go through the scripts and fix this. Testrunning them all is far to timeconsuming even though it will give me the same result (more or less), breaking with errors on the offending lines.
So, is there a way to check scripts for functionality that is not supported in >v2 other than just running the scripts and see if they break?