< Back
Get-CPowershellPath
Post
NAME Get-CPowershellPath
SYNOPSIS
Gets the path to powershell.exe.
SYNTAX
Get-CPowershellPath [-x86] [<CommonParameters>]
DESCRIPTION
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 |
+-----+-----+------+--------------------------------------------------------------+
PARAMETERS
-x86 [<SwitchParameter>]
Gets the path to 32-bit PowerShell.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-CPowerShellPath
Returns the path to the version of PowerShell that matches the computer's architecture (i.e. x86 or x64).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-CPowerShellPath -x86
Returns the path to the x86 version of PowerShell.
RELATED LINKS
SYNOPSIS
Gets the path to powershell.exe.
SYNTAX
Get-CPowershellPath [-x86] [<CommonParameters>]
DESCRIPTION
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 |
+-----+-----+------+--------------------------------------------------------------+
PARAMETERS
-x86 [<SwitchParameter>]
Gets the path to 32-bit PowerShell.
Required? false
Position? named
Default value False
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Get-CPowerShellPath
Returns the path to the version of PowerShell that matches the computer's architecture (i.e. x86 or x64).
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Get-CPowerShellPath -x86
Returns the path to the x86 version of PowerShell.
RELATED LINKS