Tuesday, July 17, 2007

Windows PowerShell

I'm trying to provide a very quick reference to windows powershell that could help the beginners and these are the same things that helped me.

Windows PowerShell is very different.

  • Windows PowerShell does not process text. Instead, it processes objects based on the .NET platform.

  • Windows PowerShell comes with a large set of built-in commands with a consistent interface.

  • All shell commands use the same command parser, instead of different parsers for each tool. This makes it much easier to learn how to use each command.

You can download and install it for free from this Microsoft web site. Make sure to check sys. requirements.

http://www.microsoft.com/technet/scriptcenter/topics/msh/download.mspx

Windows PowerShell Cmdlets

A cmdlet (pronounced "command-let") is a single-feature command that manipulates objects in Windows PowerShell. You can recognize Cmdlets by their name format -- a verb and noun separated by a dash (-), such as Get-Help, Get-Process, and Start-Service.

Ok, so here goes the question. How do you get to know which are the possible verbs and what are the possible nouns that you can use to constitute valid powershell commands or for that matter cmdlets.

The "get" cmdlets only retrieve data, the "set" cmdlets only establish or change data, the "format" cmdlets only format data, and the "out" cmdlets only direct the output to a specified destination.

Each cmdlet has a help file that you can access by typing:

get-help <cmdlet-name> -detailed

You can download the Graphical help file at this Microsoft site.
http://www.microsoft.com/downloads/details.aspx?familyid=3B3F7CE4-43EA-4A21-90CC-966A7FC6C6E8&displaylang=en

You can run Windows command-line programs in Windows PowerShell

All in PowerShell is your .NET Framework and .NET Objects world.

For example, when you get a process in Windows PowerShell, you are really getting an object that represents the process. When you view information about a process, you are viewing the properties of its process object. And, when you start a process, that is, when you change the Status property of the process to "started," you are using a method of the process object.

You can easily do string manipulation also to leverage the returned data.

Try this command in PS...

get-process findstr "iexplore"

and it will automatically filter the rows that had "iexplore" string...It gives you all the instances of Internet Explorer process... amazingly easy and handy...isn't it?

No comments:

 
Dotster Domain Registration Special Offer