Introduction to Windows 8 Power Shell
Windows had always been very weak on the command line part,so finally it began to work on a strong shell command line console, out of the research and .Net libraries comes “PowerShell”. Microsoft’s answer to Linux’s powerful shell.
If you would ever have had use the shell in ubuntu or any other linux you would know the real power of a command line console. Windows already had the “command prompt” or “cmd” but it was too weak to ever be used by programmers . It was never really developed into a full product . CMD was something that was always there but never upgraded. The PC eventually grew more friendly to normal users but lacked the firmness expected by programmers who are addicted to staying away from GUI.
The Power Shell
Power Shell is exact copy on a LINUX shell. Windows PowerShell is Microsoft’s task automation framework, consisting of a command-line shell and associated scripting language built on top of, and integrated with the .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems.
There are four kinds of commands Windows PowerShell can execute:
- cmdlets, which are .NET programs designed to interact with PowerShell
- PowerShell scripts (files suffixed by .ps1)
- PowerShell functions
- standalone executable programs
If a command is an standalone executable program, PowerShell.exe launches it in a separate process; if it is a cmdlet, it is executed in the PowerShell process. PowerShell also enables the creation of aliases for cmdlets, which are textually translated by PowerShell into invocations of the original commands.
Another concept used by PowerShell is that of a pipeline. Like Unix pipelines, PowerShell pipelines are used to compose complex commands, allowing the output of one command to be passed as input to another, using the | operator. But unlike its Unix counterpart, the PowerShell pipeline is an object pipeline that is, the data passed between cmdlets are fully typed objects, rather than character streams.
When data is piped as objects, the elements they encapsulate retain their structure and types across cmdlets, without the need for any serialization or explicit parsing of the stream, as would be the need if only character streams were shared. An object can also encapsulate certain functions that work on the contained data. These also become available to the recipient command for use. For the last cmdlet in a pipeline, PowerShell automatically pipes its output object to the Out-Default cmdlet, which transforms the objects into a stream of format objects and then renders those to the screen.
Cmdlets
Cmdlets are specialized commands in the PowerShell environment that implement specific functions. These are the native commands in the PowerShell stack. Cmdlets follow a – naming pattern, such as Get-ChildItem, helping to make them self-descriptive. Cmdlets output their results as objects, or collections thereof (including arrays), and can optionally receive input in that form, making them suitable for use as recipients in a pipeline. But, whereas PowerShell allows arrays and other collections of objects to be written to the pipeline, cmdlets always process objects individually. For collections of objects, PowerShell invokes the cmdlet on each object in the collection, in sequence.
Cmdlets are specialized .NET classes, which the PowerShell runtime instantiates and invokes when they are run. Cmdlets derive either from Cmdlet or from PSCmdlet, the latter being used when the cmdlet needs to interact with the PowerShell runtime. These base classes specify certain methods – BeginProcessing(), ProcessRecord() and EndProcessing() – which the cmdlet’s implementation overrides to provide the functionality.
Whenever a cmdlet is run, these methods are invoked by PowerShell in sequence, with ProcessRecord() being called if it receives pipeline input.
Scripting
Windows PowerShell includes a dynamically typed scripting language which can implement complex operations using cmdlets imperatively. The scripting language supports variables, functions, branching (if-then-else), loops (while, do, for, and foreach), structured error/exception handling and closures/lambda expressions , as well as integration with .NET. Variables in PowerShell scripts have names that start with $; they can be assigned any value, including the output of cmdlets. Strings can be enclosed either in single quotes or in double quotes: when using double quotes, variables will be expanded even if they are inside the quotation marks (just like linux).
According to the variable syntax, if the path to a file is enclosed in braces preceded by a dollar sign (as in ${C:\foo.txt}), it refers to the contents of the file. If it is used as an L-value, anything assigned to it will be written to the file. When used as an R-value, it will be read from the file. If an object is assigned, it is serialized before storing it.
Object members can be accessed using . notation, as in C# syntax. PowerShell provides special variables, such as $args, which is an array of all the command line arguments passed to a function from the command line, and $_, which refers to the current object in the pipeline. PowerShell also provides arrays and associative arrays. The PowerShell scripting language also evaluates arithmetic expressions entered on the command line immediately, and it parses common abbreviations, such as GB, MB, and KB.
Using the function keyword, PowerShell provides for the creation of functions, which can take parameters.
What actually is PowerShell ?
I read a lot of articles and tutorials but one thing no one mentions is that. Power Shell is just a copy of LINUX shell and runs all (almost) LINUX commands. We are yet to discover what all is there in the Power Shell. Like can we install apps using it or what all can be done.
We tried running common commands of UNIX like:
- ls
- whoami
- ps
- clear
The Screenshot after the execution of commands:
A common problem for people new to PowerShell is that function arguments are separated by spaces, not commas : : Calls the function with two arguments. (These arguments may be bound to parameters declared in the function definition or accessed by position from the $args array.)
(, ): Calls the function with a single argument, a two element array.
PowerShell allows any .NET methods to be called by providing their namespaces enclosed in brackets ([]), and then using a pair of colons (::) to indicate the static method.
For example, [System.Console]::WriteLine(“PowerShell”).
Objects are created using the New-Object cmdlet. Calling methods of .NET objects is accomplished by using the regular . notation.
For error handling, PowerShell provides a .NET-based exception handling mechanism. In case of errors, objects containing information about the error (Exception object) are thrown, which are caught using the trap keyword. However, the action-or-error is configurable; in case of an error, PowerShell can be configured to silently resume execution, without trapping the exception.
Scripts written using PowerShell can be made to persist across sessions in a .ps1 file.
We are testing and putting the PowerShell to work. If you stumble upon any new features or find something work sharing do share with us.
Learn how to code and develop new Metro Style Apps for "Windows 8"


9:21 pm
Powershell – object shell.Unix shell – text shell.
Exact copy?Rofl….
6:37 pm
I guess you should read the whole article…. with exact copy we mean on the front end and the obscure details of functionality … the attempt by widnows to add linux commands to windows… part…. the functionality of the Powershell was mentioned with clarity…
5:39 am
The reason there are Linux commands in PowerShell is to make it easier for Linux admins to migrate to PowerShell. The Linux commands are MERELY aliases that call the PowerShell equivilent.
By the way.. I didn’t know the Linux shell returned OBJECTS!?!?
11:22 am
Well still the PowereShell is too basic.
I was testing with simple commands like ->
“ls” worked but advanced options:-
ls -a
ls -i
were not working !!
And PowerShell in Windows returns objects not the Linux one …..
12:14 pm
Are you new to PowerShell? The ls and other commands are aliases to Get-ChildItem and others. They are not exact copy of what Linux equivalents do. This was done to help help Unix administrators transition easily into the new shell on Windows. You say PowerShell Microsoft’s task automation framework. So, if PowerShell is a copy of unix Shell, when did Unix Shell become a task automation framework? And, what do you mean by framework? Did you know that PowerShell existed since 2007? The way you write it here sounds as if this is something that just came up in Windows 8.
11:58 am
The power shell was present, but it was not that prominent in the previous versions of Windows and has been greatly improved for Windows 8.
And with the copy we meant the commands were copied into or imitated to suit the needs of UNIX admins.
Like the commands “ls” , “whoami” were not there in cmd.
2:59 pm
you have got it completely wrong. Windows PowerShell 2.0 was a powerful platform too. Why do you think it was not prominent? Did you know VMware, Cisco, Dell, EMC, and many more people in the industry endorsed PowerShell as their management and automation platform. For a long time, PowerShell was the only way to manage RHEV. I am not saying all this because I am a PowerShell MVP. I am saying all this because the title of this article — as it appears in the IE title bar — “Windows 9 copies Linux’s shell and names it PowerShell” is quite misleading.
You’d mentioned that “Power Shell is exact copy on a LINUX shell”. This itself is a blanket statement. There is no copy as such. The basis for all these shells is certainly POSIX but the comparison ends there. And, as you have written in the articles, it is not “power shell”. It is PowerShell.
I’d love to see known sites and authors do the home work before posting such content. There is a huge community around the technology areas and you lose your credibility by writing like this.