Path to Powershell.exe (v 2.0)

Where is the Powershell (version 2.0) located? What is the path to Powershell.exe? I have Windows Server 2008 and Powershell installed. When I look at this folder:

PS C:WindowsSystem32WindowsPowerShell> dir


    Directory: C:WindowsSystem32WindowsPowerShell


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
d----         20.4.2010     17:09            v1.0

I have only Powershell v1.0. But when I type

PS C:> $Host.version

Major  Minor  Build  Revision
-----  -----  -----  --------
2      0      -1     -1


PS C:>

It shows that I have v2.0 installed.


I believe it's in C:WindowsSystem32WindowsPowershellv1.0 . In order to confuse the innocent, MS kept it in a directory labeled "v1.0". Running this on windows 7 and checking the version number via $Host.Version (Determine installed PowerShell version) shows it's 2.0.

Another option is type $PSVersionTable at the command prompt. If you are running v2.0, the output will be:

Name                           Value
----                           -----
CLRVersion                     2.0.50727.4927
BuildVersion                   6.1.7600.16385
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

If you're running version 1.0, the variable doesn't exist and there will be no output.

Localization PowerShell version 1.0, 2.0, 3.0, 4.0:

  • 64 bits version :C:WindowsSystem32WindowsPowerShellv1.0
  • 32 bits version : C:WindowsSysWOW64WindowsPowerShellv1.0

  • 我认为$ PsHome拥有你之后的信息?

    PS .> $PsHome
    C:WindowsSystem32WindowsPowerShellv1.0
    
    PS .> Get-Help about_automatic_variables
    
    TOPIC
        about_Automatic_Variables ...
    
    

    Here is one way...

    (Get-Process powershell | select -First 1).Path
    

    Here is possibly a better way, as it returns the first hit on the path, just like if you had ran Powershell from a command prompt...

    (Get-Command powershell.exe).Definition
    
    链接地址: http://www.djcxy.com/p/29008.html

    上一篇: 在Windows7 PsSnapin Web管理

    下一篇: Powershell.exe的路径(v 2.0)