Powershell, Bash command window on Windows and Linux
Powershell is a Bash-style command window for Windows (and now Linux), but with a domain-specific scripting language.
This successor to the ancient MS-DOS window offers advanced scripting features.
It transitioned in April 2011 under the Community Promise license, making it free and can be implemented under any platform. So under Linux, what was done with the Pash project, which runs on Mono. In 2008, its development was discontinued, but in 2012 the project was resumed by donors. Now the project is outdated, from August 18, 2016.
On August 18, 2016, the Powershell source code was opened by Microsoft and becomes available on Linux and Mac. Based on .NET Core, it provides access to an extensive library of functions .
It can be downloaded on GitHub. After Bash in the Linux subsystem in Windows 10, so we have the choice of a full command line with the opposite Powershell in Linux!
Scripting and Administration Tool
The command line window, so familiar to Unix or Linux or MS-DOS users and also often called the MS-DOS window, does not disappear under Vista, on the contrary, it approaches what Linux offers and is being upgraded with very powerful features. In addition, it is also available for Windows XP through downloads on the Microsoft website.
The codename was Monad, in reference to a term used by Leibniz in philosophy that treats the world as components, monads, interaction, and harmony.
Powershell allows you to manage the computer, manage processes and sessions connected by users, all network management and therefore replace Perl.

Examples of innovative features in Powershell
Powershell provides access to most Windows features, including services, applications, voice. In addition, its display no longer has anything to do with the MS-DOS screen, it can be made in graphics...
You can select the following code samples using the mouse and right-click in Powershell to insert the code and execute it...
Microcalculator
It is built in. You can enter a mathematical operation or formula and get the result:
PS> (2 + 3) * 5
25 should be shown.
In fact, many mathematical functions are available with the System.Math class, which can be used with a command such as: PS> [System.Math]:: Pow (2,3)
whatif
This option allows you to see what the command is doing without actually executing it and therefore without any real effect.
Just add:
-whatif
has any command to run in virtual mode.
Transcript
This function automatically saves the transmitted commands and the received results in a file. Transcript mode starts with:
PS> Start-Transcript -Path chemin-nom-fichier
(path-name-file - script file with its own directory), and it is stopped using:
PS> Stop-Transcript
Use apps
Windows applications can be ordered from the command line. To do this, create a new object and pass the -com parameter to use the program functions.
$nom = new-object -com nom-application.ocx
Voice
Your computer can talk, try the following command:
$spVoice = new-object -com "SAPI.spvoice" $spVoice.Speak("Hello the World!")
I use the sentence in English because the pronunciation is in English and French is quite comical that way!
Graphics system
Powershell can show graphs as a result by command.
Programming
It has a real scripting language similar to Bash on Linux. For example, the foreach management structure is implemented. You can define functions
Commands are separated by semicolons and can therefore be linked on a single line.
Code Editor
Enter to display the write-enabled script editor and debug functions. But Visual Studio Code undoubtedly provides more comfort.
Chain (oil pipeline)
The | symbol allows you to apply one command to the result of another. For example, to apply the format-list or format-table command or another format to the output of the get-service cmdlet, type:
get-service | format-list
Creating files
Using the format commands and the Out-file command, which redirects the results to a file, you can create text files.
Alias
With SetAlias, you can associate a shorter word with a command, such as Clear-Host, to simplify or use the commands we are used to.
Running a script in a file
The script file has the extension. "ps1."
But by default, script execution is prohibited. You can enable this by maintaining Remote Access Protection with this command:
Set-ExecutionPolicy RemoteSigned
Unix compatibility
Some Unix commands are recognized by Powershell, such as ls, which is equivalent to dir (but the parameters are different).
Accessing System Data
Powershell returns all relevant information about the Bios, processor and all computer system components, operating system, software, updates, etc.
For example, try the following command:
Get-WmiObject -Class Win32_BIOS -ComputerName .
not forgetting the dot at the end, and you'll learn all about your computer's BIOS!
To find out the free space on your hard drives, try:
Get-WmiObject -Class Win32_LogicalDisk
Many other examples are provided in the user guide.
Cmdlets extend the base language
"Commands" are internal applications that provide access to Windows resources.
The previously used New-Object parameter is a cmdlet. All cmdlet names consist of two words separated by dashes.
Enter, for example:
PS c:\get-service
and you'll get a list of all the services available on Windows.
Cmdlets appear as objects, while on Unix they are passed between text commands. But the results are given as text when they are displayed on the screen.
Further information
Download from Download Center on the Microsoft website. The archive contains a French user manual and a memo for the Windows Powershell scripting language.
- Powershell Scripting. French site dedicated to Powershell.
- Official website. English.
- Download for Windows, Mac and Linux on GitHub. There is source code and ready-made installers .
- Memory Help.
- Official blog. (English).
See also:
- Windows 10, a few tricks. How to remove refractory applications from Windows.