I\'d like to use .NET in some PowerShell scripts I\'m about to write -- how do I know/declare which version of .NET I\'m dealing with when these scripts run?
And is
...no, you cannot choose which .NET version you can run the script under -- George Howarth
Woah, that's not true! You can specify which version of .NET that PowerShell uses. The key is the .NET standard application configuration file, which takes the form [appname].exe.config. You can drop that in the same directory as most .NET applications -- including the PowerShell and PowerShell ISE executables -- and the CLR will automatically load any recognizable options specified within the configuration file. One of those options is the CLR version you want the application to use.
This is documented in detail in the question: How can I run PowerShell with the .NET 4 runtime?. In particular, see Emperor XLII's post.