A look at the Toshiba Portégé R600 with 512GB SSD
July 2, 2009 – | No Comment

There aren’t many better ways of gaining recognition for all the effort you have put in to be greener than from an organisation like Greenpeace. The Toshiba Portégé R600 won its category in the Greenpeace …

Read the full story »
Downloads

Things to download free, from posters and shortcut guides to white-papers and checklists

How To & Tutorials

These handy problem solving tips and advice should save you some time

Industry News

News and commentary from news in the technology industry

Software

Explore recommended software applications from around the Internet

Technology Terms

We regularly take a technology related term and try to make sense of it in the real world.

Home » Technology Management

Power Shell

Submitted by jasonslater on January 23, 2008 – One Comment

Power Shell is Microsoft’s more recent command line interface (CLI) – during development it was called Monad. Until a recent Seminar that touched upon Power Shell I only really saw it as something that was used in Exchange Server 2007 but my eyes were widened when I saw demo’s of it in action. Essentially it is a way of typing word commands at a prompt and getting information back and manipulating information instead of using a graphical user interface, so for example in windows you could click My Computer to get a list of drives. In Power Shell you can type the command (cmdlet) get-psdrives and get something back as shown in the image. The interesting thing you may notice from the image is that Power Shell doesn’t just focus on disk drives – but we’ll get to that later.

image

CLI are already popular on devices and other operating systems like UNIX. You may be thinking that there is already a CLI under the guise of command.com and you would be right – however Power Shell takes that idea and extends it so you can navigate areas other than file systems such as the Registry and Certificate Stores as easily as you would change to a folder and list and manipulate its contents. At the seminar we were told that one of the import differences between say a UNIX command and a Power Shell command is that in Power Shell the information returned from a command is an object. For example if you were to get a disk space list in Unix and store it in a variable it would be a ‘snapshot’ containing information – whereas in Power Shell an object is returned and that object reflects the actual situation and can be further manipulated using any associated object data that is available – so if the disk space changed since the last time you ran the command it would be reflected next time you used the results of the previously run command.

When a command produces information it can, as in UNIX, be piped to another command. Piping is simply a way of saying that the results of command ‘A’ get passed to command ‘B’ as input. Anyway, typically in other CLI’s this data has to be parsed as it is often a text string; parsing simply means breaking a large amount of text up into smaller bits of text. Power Shell on the other hand, being object based, pipes the object itself so it doesn’t need parsing. You can simply access information about the object – for example, if I get a list of disk drives and pipe the output to another command that gets the disk space.

If you are familiar with commands like dir or ls then you will be pleased to know these are aliased in Power Shell. Aliasing simply means the same as it does in movies that something is pretending to be something else. So when you type dir at the Power Shell it is really running the Get-ChildItem cmdlet and when you type cd Power Shell is really running its Set-Location cmdlet.

The structure of a Power Shell command, termed a cmdlet, is typically in the form:

verb hyphen noun

So, an example Power Shell command would be get-command or get-help. It is possible to build up series of commands into a text file and create your own cmdlet. This could also be called scripting. When creating and sharing cmdlets you may need to get familiar with the cmdlet Set-ExecutionPolicy. Security plays an important part of scripting in Power Shell and you may want assurances that scripts you download are genuine, and people downloading your scripts may want the same assurances; there are a number of Execution Policies including Unrestricted, AllSigned, RemoteSigned. You can find out more information by typing Get-Help Set-ExecutionPolicy.

References

Wiki have an introduction to Powershell:

http://en.wikipedia.org/wiki/Windows_PowerShell

Microsoft also have an introduction to Power Shell:

http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx

The PowerShell team have their own Blog:

http://blogs.msdn.com/PowerShell/

To see how to do something useful with String Searching:

http://www.microsoft.com.nsatc.net/technet/scriptcenter/topics/winpsh/selectstring.mspx

Share and Enjoy:
  • Digg
  • del.icio.us
  • E-mail this story to a friend!
  • StumbleUpon
  • Technorati
  • TwitThis

One Comment »

Leave a comment!

Add your comment below, or trackback from your own site. You can also subscribe to these comments via RSS.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

This is a Gravatar-enabled weblog. To get your own globally-recognized-avatar, please register at Gravatar.