Я хочу запустить следующую команду из Powershell 5, но заставить ее выполнить с помощью Powershell 6:
$PSVersionTable.PSVersion.Major
Как это можно сделать?
Ожидаемое возвращаемое значение от команды должно быть '6'.
Я получаю это:
pwsh -command "$PSVersionTable.PSVersion.Major"
System.Collections.Hashtable.PSVersion.Major : The term 'System.Collections.Hashtable.PSVersion.Major' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ System.Collections.Hashtable.PSVersion.Major
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (System.Collections.\u2026ble.PSVersion.Major:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException