Gets the path to powershell.exe.
Get-PowershellPath [-x86] [<CommonParameters>]
Returns the path to the powershell.exe binary for the machine's default architecture (i.e. x86 or x64). If you're on a x64 machine and want to get the path to x86 PowerShell, set the x86
switch.
Here are the possible combinations of operating system, PowerShell, and desired path architectures, and the path they map to.
+-----+-----+------+--------------------------------------------------------------+
| OS | PS | Path | Result |
+-----+-----+------+--------------------------------------------------------------+
| x64 | x64 | x64 | $env:windir\System32\Windows PowerShell\v1.0\powershell.exe |
| x64 | x64 | x86 | $env:windir\SysWOW64\Windows PowerShell\v1.0\powershell.exe |
| x64 | x86 | x64 | $env:windir\sysnative\Windows PowerShell\v1.0\powershell.exe |
| x64 | x86 | x86 | $env:windir\SysWOW64\Windows PowerShell\v1.0\powershell.exe |
| x86 | x86 | x64 | $env:windir\System32\Windows PowerShell\v1.0\powershell.exe |
| x86 | x86 | x86 | $env:windir\System32\Windows PowerShell\v1.0\powershell.exe |
+-----+-----+------+--------------------------------------------------------------+
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
x86 | SwitchParameter | Gets the path to 32-bit PowerShell. |
false | false | False |
Get-PowerShellPath
Returns the path to the version of PowerShell that matches the computer's architecture (i.e. x86 or x64).
Get-PowerShellPath -x86
Returns the path to the x86 version of PowerShell.