"Kicking off Powershell (PS)" for techs

So things are getting pretty hot around here and lots of devs and admins are needing more control over their systems. Command line just doesn't cut it with all this new technology so we need more power, flexibility and control.

Monad has been the talk of the town amongst many engineers in PSS and sooner or later it will have an important part to play in all the products we currently support hence we're all gearing up for this cool new technology which marketing have finally branded "POWERSHELL"

I took some time out to get a real simple overview for newbies and thought I'd add it to my blog too for those looking to get busy with it. Here Goes...

"Monad" the term is no longer used and "Windows Powershell" is the new kid. Its the next generation interactive command line shell and scripting language in Windows that provides task automation and complete scripting solutions built on top of .NET. It allows developers and administrators total control of their windows environments.

What: Windows Powershell is a new command line shell environment and scripting language developed for the Windows platform. The terms "MSH" and "Monad" are no longer used and are now replaced by the terms "PS" and "Windows PowerShell" respectively.

When: Currently available as a standalone component, and will be installed with Ex2007 and MIIS, the plan is to have it in all future server and operating systems. The new shell environment is designed by administrators wanting more control over their windows systems. It provides a robust, clean way to interact with the system. The RTM date for the product will be announced in Oct ‘06 by Marketing. Public has access to RC1 (x86 & x64 builds)

Where: Powershell is supported on Windows XP SP2, Server 2003 SP1 and Windows Vista. You need Framework 2.0 installed located here. Powershell is available from here. Install it and thats all you need. You can find more Monad resources on ms.com here.

Why: Admins and developers have asked for it. They want more control of their systems from a reliable scriptable language. With Powershell, they can access every part of the operating system including registry, files, drives, event logs, services, applications, WMI and much more. You can write and customise scripts within the environment and have them compiled. You can query objects within the system and output data to files, databases or straight out in xml. You can query the internals of the system. It’s command line (cmd.exe) on steroids.

When you start Powershell you will see a cmd prompt

      Microsoft Command Shell

      Copyright (C) 2006 Microsoft Corporation. All rights reserved. 

      PS D:\MshScripts>

Most powershell commands are identified by a pair of words, one verb and one noun, separated by a hyphen.The verb describes the action (such as get or set) while the noun represents the target of the action (such as process or location).

These are called Cmdlets (pronounced "command-lets"). PS provides a framework within these cmdlets. A cmdlet is implemented as a managed class (built on the .NET Framework) that implements a well-defined set of methods to process data.

Examples:

PS D:\MshScripts> get-process

Run the cmdlet to generate a list of currently active processes within the system.

PS D:\MshScripts> get-process [ws]*

Show me all processes beginning with “s” or “w”

PS D:\MshScripts> get-wmiobject win_32_bios

Show me the current bios for the machine

PS D:\MshScripts> get-wmiobject

Run this, and it asks you for a wmi class to show - thats just cool!

10 Cool things to discover with PowerShell :

1) POWERSH.exe or PS.exe is the new Shell environment (the old windows shell was called cmd.exe)

2) Look for help in the shell by typing “powershell -help” or "get-help" anywhere within the shell

3) The terms "MSH" is replaced by “PS” and "Monad" is now called "Windows PowerShell" respectively.

4) get-command is the most helpful cmdlet available

5) Use "get-help" cmdlet to discover what cmdlets are available, there are over 100 scripts available

e.g PS D:\MshScripts> get-help get-process

6) Cool tracing ability in the shell by setting "$env:PSEnableTrace=”True” and calling “set-psdebug” cmdlet

7) Get a list of all applications processes by running = "get-process"

8) On live production environments, all scripts should be signed and execution policy should be set to run only signed scripts.

9) Using Namespace providers is the best way to interact with the system.

10) Navigate the registry using Powershell, just like a filesystem

e.g PS D:\MshScripts> cd hkcu

PS D:\MshScripts> dir

Check out the Windows Server Scripting newsgroup