Introduction to PowerShell Executable
PowerShell.exe is the executable file of the that is used by system administrator for configuration management and other task automation related activities. The .exe stands for an executable file. Some executable files possess a threat to the system but since Powershell.exe is a product of Microsoft there are no such harms associated with it. The executable file can execute both PowerShell cmdlets and scripts. This article will cover in detail the exe file of the 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 and so it can be relatively assumed to be a safe file. The percentage of this file 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 referred as PowerShell core and it has been made open source and it uses the functionality of .net core. The binary file has been renamed as pwsh.exe in windows and pwsh in mac and linux.
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 the PowerShell to be not closed after running the cmdlets.
- -STA:
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.
- -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 default end point on the local machine or custom end point 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. On the off chance that the esteem of Record could be a record way, the script runs within the neighborhood scope (“dot-sourced”), so that the capacities and factors that the script makes are accessible within the current session. Record must be the final parameter within the command. All values written after the Record parameter are translated as the script record way and parameters passed to that script.Parameters supplied to the script are sent as strict strings, after translation by the current shell. For illustration, in case you’re in cmd.exe and need to pass an environment variable esteem, it is done in the following manner: powershell.exe -File .viki.ps1 -TestParam test. If the value is going to be a file path, it should be given at the end as the character that are specified after the parameter as treated as file path by default.
- -ExecutionPolicy <ExecutionPolicy>:
This is used to set the current sessions default execution policy and it is being stored in the environment variable, $env:PSExecutionPolicyPreference. However, the value set in the registry is not affected because of this.
- -Command:
This denotes the commands to be executed. This is like running the commands at 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 being a string, it should be specified at the end. The script block is considered only when triggered from another PowerShell exe.
Conclusion
Thus, the article explained in detail about the various locations of PowerShell executable file. It also explained in detail about PowerShell.exe along with its various parameters. It should be noted on how to trigger the PowerShell.exe from command prompt. To learn more in detail it is advisable to explore running files from Powershell.exe from cmd prompt.
Recommended Articles
This is a guide to PowerShell Executable Location. Here we discuss introduction to PowerShell Executable, various locations of PowerShell executable file. You can also go through our other related articles to learn more –
2 Online Courses | 1 Hands-on Project | 4+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses