PowerShell.exe is the name of the popular programming and scripting language interpreter. Microsoft created the PowerShell language in order to provide powerful scripting shell and commands to manage Microsoft Windows operating systems like Windows 7, Windows 8, Windows 10, Windows Server. The PowerShell can be used for configuration management, task automation, system tasks, process management, etc. The PowerShell first provided with the Windows 7 and Windows Server 2008 R2.
PowerShell.exe provides a command line interface in order to run PowerShell scripts and commands. PowerShell command line interface can also execute MS-DOS commands without problem. PowerShell.exe can be executed or opened in different way. But one of them is starting from the “Start Menu” by typing “powershell“.
Alternative way to start PowerShell is running the “powershell” command from the Windows Run.
Print PowerShell Help
PowerShell is an advanced scripting language and command-line interface which provides a lot of features and options. Some basic information about the PowerShell interpreter which is PowerShell.exe can be displayed with the -? or /? or -Help options like below.
The powershell help will be like below.
Start Specific PowerShell Version (v2 or v3)
Powershell is an evolving scripting language that has multiple versions. The powershell.exe supports current and previous PowerShell versions for backward compatibility for commands and scripts. The PowerShell version we want to use can be specified with the -version command like below. Currently, the 2.0 and 3.0 versions can be selected. Following commands can be executed via the MS-DOS command-line interface or Windows Run.
Start PowerShell 3.0:
powershell.exe -version 3.0
Start PowerShell 2.0
powershell.exe -version 2.0
Hide Copyright Banner
When started the beginning of the powershell.exe console prints come copyrithg banner which is trivial for us. The copyright information is like below.
Windows PowerShell Copyright (C) Microsoft Corporation. All rights reserved. Try the new cross-platform PowerShell https://aka.ms/pscore6
This copy right information or banner can be disabled or do not displayed at the starts by using the -NoLogo option like below.
Set PowerShell.exe Window Style (Normal, Minimized, Maximized and Hidden)
The powershell.exe window is started as normal. But we may need to change the window style for the start like below.
- Minimized will do not put the powershell windows on the desktop.
- Maximized will fill the screen.
- Hidden will not show the powershell screen and runs in the background.
powershell -WindowStyle "Maximized"
Do Not Present Interactive Prompt To User
Normally the PowerShell.exe provides an interactive prompt to the user whith a cursor which is used to put powershell commands. The interactive prompt can be disabled with the -NonInteractive option like below.
Run Specified Script or Command In PowerShell Interpreter
One of the most powerful features of PowerShell is executing PowerShell commands and script and returning the result or printing explicitly. This can be useful in order to execute powershell commands and scripts inside the MS-DOS (cmd.exe). We will use the -Command option and provide the PowerShell script or PowerShell command between double-quotes.
powershell -Command "Get-ChildItem"