Tuesday, December 4, 2007

Windows PowerShell walkthrough !!

Windows Powershell is the new command line utility targeted for system administrators and developers. Its can be used with Windows 2003 Server , XP SP2 , Vista and the Windows 2008 Server.

The implementation of the powershell is really unique , unlike other shells, which accept and return text. Powershell is built on top of the .NET (CLR) accepting and returning .NET objects.This fundamental implementation brings about new methods to the management and configuration of Windows.

The early implementations of shells like cmd.exe , KSH , CSH and BASH Unix shells , operated using a command utility in a new process and returned results in the form of text. The Powershell uses .NET objects ( cmdlets) pronounced as "command-lets". So , it doesnt process text , but processes objects based on the .NET platform.

Powershell incorporates functionalities like accessing data stores like the registry , file system , certificate signatures etc.
It allows loads of other dimensions like managing profiles , using Windows programs , customizing powershell , support for scripting , managing errors etc.

Now we shall look at a few "common user functions" that the powershell offers rather than looking at how we interact with the .NET objects.

Essentially it has a few commands similar to the UNIX shell like the "clear" , "man" for clearing the screen and accessing manual pages respectively.

Lets have a look at some basic functions :

This is how the powershell will look on running powershell.exe


1. To obtain the current system date type PS C:\get-date

PS C:\man get-date ( allows to view format for using cmdlet)



2. PS C:\ get-process ( allows to view currently running processes )


3. PS C:\ get-service (allows to view status of windows services)

Now lets interact on "aspnet_state" service circled above. This service is currently STOPPED.
To make sure this is running we can "start" this service using the command
PS C:\ start-service aspnet_state
PS C:\ get-service


We shall now try stopping the "aspnet_state" again


4. PS C:\ man ( lists all the alias , cmdlets , help files , providers etc )




These were a few examples of what the Powershell offers to an "advanced" user who has the credentials of configuring and managing the Operating System.

The powershell is an easy to use and powerful mechanism of managing the operating system , following an easy syntax and has loads to offer in terms of management and development.

So , download the powershell & manuals and be powered to manage your OS.

We will see more functionalities in the upcoming posts , thank you :)

References : Powershell manual , MSDN