Windows PowerShell is a new command-line shell and task-based scripting technology that provides comprehensive control and automation of system administration tasks.
However, I became more dissatisfied with the native Windows command shell. I learned to program the UNIX shell (bash to be specific) a bit and found it to be way more advanced than the Windows shell.
Aesthetically, PowerShell doesn’t look too different from most existing shell scripting clients. In fact, on a superficial level you could probably be fooled into thinking that it is exactly the same as either bash or cmd. PowerShell, however has a very powerful underlying structure that ties in neatly with the registry, the .NET Framework and (more obviously) the file system.
I think the text shell is the preferred way to do system administration for most people who have to take care of a system.
Let’s have a closer look:
PowerShell is available for Windows XP, 2003 Server and Vista.
- Download .Net 2.0 Framework
- Download PowerShell
- Unzip the downloads and run their respective setup. I used all the defaults.
Type “Powershell -?” and you’ll see the command line parameters you can use to start PowerShell. There are a couple that are interesting here.
Using PowerShell is a bit different than any other command shell I have used. It is centered around the concept of cmdlets (command lets), which are commands that manipulate objects to perform a single task.
Every command in PowerShell returns a collection of objects. These objects can be manipulated in the exact same way as if you were using an object-oriented language. The ls/dir command creates a collection of file objects which can have any .NET function performed upon them from within the shell.
When you’d like to use a command with a pipe you can do it this way:
PowerShell -NoProfile -NonInteractive -Command "Get-Process *ss |sort handles"
This PowerShell syntax is obviously more verbose but it is also more powerful.
Also consider using the â-confirmâ parameter to test configurations before execution for certain commands.
Killing Task the easy way with Powershell instead of Task Manager. For example we attemp to kill Winamp.
Once the Process ID has been identified, you can kill the errant process by entering:
That way is also possible:
get-process wina* | stop-process
Windows PowerShell includes an untyped 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), and error handling, 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. While the language is untyped, internally the variables are stored with their types, which can be either primitive types or objects.
Microsoft’s PowerShell is a solid step forward in script-language design.
There’s a whole bunch of scripts available on the internet, some are just one line others are really complex - there are limits set on your creativity.
Also remote adminstration via ssh can be done more enhanced. Just use freeSSHd server and log in with Putty (ssh client):
$PowerShell/v1.0/powershell.exe -Command -
Another alternative solution for a better windows shell is win-bash which is based on nt_bash which was an early bash port for windows nt started by Mountain Math Software some years ago. As far as I know, the nt_bash port project stopped in alpha status and has been never finished.
Download Windows PowerShell 1.0: [link]
You can also have a look at the preview release of Version 2.0 from November 6, 2007.
Win-bash project on sourceforce: [link]