#powershell -version is not recognized

Note that powershell.exe /? shows the syntax to execute PowerShell from a command prompt. Nevertheless, running

C:\> powershell -noprofile -version 2.0
-version : The term ‘-version’ 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
+ -version 2.0
+ ~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-version:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

fails … … whereas the following works (even though the -Help syntax does not clearly specify strict placement of the -version parameter to PowerShell.exe):

C:\> powershell -version 2.0 -noprofile
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

Name : ConsoleHost
Version : 2.0
InstanceId : …
UI : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace : System.Management.Automation.Runspaces.LocalRunspace

Leave a Reply