Friday, June 8, 2012

Spicy Windows PowerShell

In today’s business world it is important to get as much done in as little time as possible. People are finding ways to automate every repetitive task for which they’re responsible. Consistency is important when automating tasks so that every administrator on the team is equally capable of stepping in to help other team members when necessary. For more information on the background and overview of PowerShell visit

Microsoft has designated PowerShell as part of its common engineering criteria for all server products.

PowerShell like any language consists of commands, variables, functions, flow control methods, and other features necessary to enable work to be done. Because it is an interpreted language, the scripts don’t have to be compiled into an executable form to be run.

A cmdlet (command-let) is a common-line utility built into PowerShell to provide some functionality. These cmdlets use a verb-noun naming convention, so it’s fairly easy to understand what they’re doing. Microsoft has provided about 130 built-in cmdlets with the default installation of PowerShell, and additional cmdlets are installed depending on various server products that may be running.

Cmdlets are frequently aliased. In other words, a different command can be entered to run the cmdlet, rather than using its own name. For example, when browsing a directory, the PowerShell cmdlet to view the contents of the current directory is Get-ChildItem. If you’re familiar with DOS you’d use dir. With Unix, you’d use the ls command. All three of these commands do the same operation, and both dir and ls are included with PowerShell as aliases of the Get-ChildItem cmdlet.

A feature of Unix shell scripting environments is the capability to “pipe” the results of one command into another command’s input buffer. This is a feature of shell scripting that makes it so powerful – the ability to string multiple commands together to provide information quickly. PowerShell provides this ability, but differs from Unix shell scripting in that the Unix pipe sends text from one command to another, whereas PowerShell pipes objects from one cmdlet to another. Unix scripts must parse the text from one command using commands such as grep, awk, and sed to format the text in a form the next command expects. PowerShell’s objects are understood by the receiving cmdlet and no such parsing is required.

More information on the features of PowerShell can be found at

For getting started with PowerShell visit

Below is a comparison chart of PowerShell cmdlets with similar commands:

PowerShell (Cmdlet)
PowerShell (Alias)
gci, dir, ls
List all files / directories in the (current) directory
gc, type, cat
Get the content of a file
List available commands
help, man
Help on commands
cls, clear
Clear the screen[Note 1]
cpi, copy, cp
Copy one or several files / a whole directory tree
mi, move, mv
Move a file / a directory to a new location
ri, del, erase, rmdir, rd, rm
rm, rmdir
Delete a file / a directory
rni, ren, mv
Rename a file / a directory
gl, pwd
Display the current directory/present working directory.
Change the current directory to the directory most recently pushed onto the stack
Push the current directory onto the stack
sl, cd, chdir
Change the current directory
Pipe input to a file or variable, then pass the input along the pipeline
echo, write
Print strings, variables etc. to standard output
gps, ps
tlist,[Note 2] tasklist[Note 3]
List all currently running processes
spps, kill
Stop a running process
Print lines matching a pattern
sv, set
env, export, set, setenv
Set the value of a variable / create a variable

No comments:

Post a Comment