I have a script that I need to run AS Powershell 7 because only Powershell 7 has the command I need.
When I run $PSVersionTable
in a .PS1 script from VSCode I get:
Name Value
---- -----
PSVersion 7.0.1
PSEdition Core
When I run that same .PS1 script from command prompt using powershell testscript_writefile.ps1
, I get:
Name Value
---- -----
PSVersion 5.1.14393.3471
PSEdition Desktop
How can I execute a Powershell script AS Powershell 7 instead of Powershell 5?
Best Answer
Just run
instead of