Updated June 23, 2023
Introduction to PowerShell Executable
The system administrator uses PowerShell.exe as the executable file for configuration management and other task automation-related activities. The “.exe” extension in PowerShell.exe signifies that it is an executable file. The executable file can execute both PowerShell cmdlets and scripts. This article will cover in detail the exe file of PowerShell.
Syntax:
The following cmdlet can be used to identify the location of the exe file
(Get-Process -Id $pid).Path
the output will be as below
The PowerShell.exe is a signed file by Microsoft, so it can be assumed to be a safe file. The percentage of this file that can be considered dangerous security-wise is 3%. The size of the file is 437 KB. The size of the PowerShell_Ise.exe is 208 KB.
Locations on 64-bit Operating Systems
The following are the locations on 64-bit operating systems.
-
32-bit PowerShell.exe:
It is available in the following location.
%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell.exe
-
64-bit Powershell.exe:
It is available in the following location.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
-
32-bit PowerShell_ISE.exe:
It is available in the following location.
%SystemRoot%\SysWOW64\WindowsPowerShell\v1.0\powershell_ise.exe
-
64-bit Powershell_ISE.exe:
It is available in the following location.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell_ise.exe
Locations in 32-bit Operating Systems
The following are the locations in 32-bit operating systems.
-
32-bit PowerShell.exe:
It is available in the following location.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
-
32-bit PowerShell_ISE.exe:
It is available in the following location.
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell_ise.exe
Starting from PowerShell version 6, it is commonly referred to as PowerShell Core. PowerShell Core has undergone significant changes compared to previous versions. It is now an open-source project and leverages the functionality of .NET Core.
Finding the PowerShell Location in the System
The below cmdlet can be used to find out the location of the exe.
Input:
(get-command PowerShell.exe).Path
Output:
Syntax:
PowerShell[.exe] [-PSConsoleFile <file> | -Version <version>] [-NoLogo] [-NoExit] [-Sta] [-Mta] [-NoProfile] [-NonInteractive] [-InputFormat {Text | XML}] [-OutputFormat {Text | XML}] [-WindowStyle <style>] [-EncodedCommand <Base64EncodedCommand>] [-ConfigurationName <string>] [-File - | <filePath><args>] [-ExecutionPolicy <ExecutionPolicy>] [-Command - | { <script-block> [-args <arg-array>] } | { <string> [<CommandParameters>] } ]
Parameters:
- -PSConsoleFile <FilePath>:
This is used to load the file specified PS file in the console. To import, the name and the path of the PS file must be specified. To create a new one, the export-console cmdlet should be used.
- -Version <PowerShell Version>:
This denotes the Powershell version that needs to be started. It can either be 2.0 or 3.0. However, the supplied version should be available on the system; else an error will be thrown.
- -NoLogo:
This is used to hide the banner while starting the PowerShell.
- -NoExit:
This denotes that the PowerShell is not closed after running the cmdlets.
- -STA:
This statement suggests that you can start PowerShell using the single-threaded concept. In PowerShell version 2.0, the default behavior is multi-threaded execution, while in PowerShell version 3.0, the default behavior is single-threaded execution.
- -MTA:
This denotes that the PowerShell should be started using single-threaded concept. In PowerShell version 2.0, multi-threaded is the default, whereas in PowerShell version 3.0, single-threaded is the default.
- -NoProfile:
This denotes that the PowerShell profile should not be loaded.
- NonInteractive:
This denotes that a prompt shouldn’t be displayed to the user during execution.
- -InputFormat {Text | XML}:
This specifies the format of input being sent to PowerShell. It can either be text or xml.
- -OutputFormat {Text | XML}:
This specifies the format of output being sent from PowerShell.It can either be text or xml.
- -WindowStyle <Window style>:
This denotes the style of the PowerShell window. The accepted values are Normal, minimized, maximized, or hidden.
- -ConfigurationName <string>:
This denotes the endpoint configuration of the PowerShell. This can be either a default endpoint on the local machine or a custom endpoint pertaining to user requirements.
- -File – | <filePath><args>:
if “-“ is specified, standard input is considered. A normal session is started if the cmdlet is run without “-. “ This is like running without the file param. If the esteem of Record could be a record way, the script runs within the neighborhood scope (“dot-sourced”), so the capacities and factors the script makes are accessible within the current session. The record must be the final parameter within the command. To illustrate, if you are in the cmd.exe environment and need to pass an environment variable “esteem”, you would do it in the following way: powershell.exe -File .viki.ps1 -TestParam test.
- -ExecutionPolicy <ExecutionPolicy>:
This command sets the default execution policy for the current session in PowerShell. The value is stored in the environment variable $env:PSExecutionPolicyPreference.
- -Command:
This denotes the commands to be executed. This is like running the commands in the PowerShell window. To stop the execution, NOExit parameter must be set. The value of this parameter can either be a string or a script block. If the value is “-, “the value is read from standardized input. In case of value is a string, it should be specified at the end.
Conclusion
Thus, the article PowerShell Executable Location explains in detail the various locations of PowerShell executable files. It also explained in detail about PowerShell.exe along with its various parameters. It should be noted how to trigger the PowerShell.exe from the command prompt. To learn more in detail, exploring running files from Powershell.exe from the cmd prompt is advisable.
Recommended Articles
This is a guide to PowerShell Executable Location. Here we discuss an introduction to PowerShell Executable Location and various locations of PowerShell executable files. You can also go through our other related articles to learn more –