Sometimes, when I write a script on my computer under Windows 10 (PowerShell 5.0), I use commands, options or aliases that are not available in earlier versions of PowerShell, for example, the -persist new-psdrive not available in PowerShell 2.0, which all of us Win7 machines.
in order to correctly install the #requires -version x operator, I need to know if there are commands in my script that are not available in previous versions of PowerShell. When you wrote code with 1000 lines, it would be a little difficult to find inaccessible commands in a script.
Is there a way to test this programmatically, except to just run the script in different PowerShell environments and see what happens?
source share