Windows Insider

Windows PowerShell Is Not a Scripting Language

I find myself amazed at how many IT professionals still avoid the command line.

Even if you're no longer a hands-on, technical IT practitioner, you've surely got some familiarity with it. The command line text-based interface has been around since long before the first GUI appeared. It is, in fact, so old that today's nth-generation Windows PowerShell-enabled command line now ships with many almost-graphical elements of its own.

Windows PowerShell is ridiculously powerful. Using today's Windows PowerShell, a skilled professional can quickly craft a useful single-line command. All at once, that single line can interrogate remote computers, interact with Active Directory, accomplish one or more actions and report back with a fully manipulatable "object." This object can ultimately take the form of a dynamically constructed table, a list of data, or even an exported .CSV or .XML document for use in some external IT applications. Using the miracle of pipelining, that same Windows PowerShell expert can string together a series of cmdlets, elegantly feeding the output of one cmdlet into the next -- all the way down the pipeline to some concluding result.

Yet, with all its elegance and power, why aren't more IT professionals embracing Windows PowerShell today? If it is possible -- and indeed it is -- to accomplish so much with so little, why aren't more IT pros lining up in droves to learn and make use of its ridiculously powerful capabilities? I believe that Windows PowerShell has a perception problem.

I discovered this perception problem only recently. In the past few months, another of Redmond's columnists, Don Jones, and I have been contracted by a major software vendor to develop training on Windows PowerShell. Given almost complete flexibility in designing the courseware, Jones and I took a step back from the Microsoft messaging as well as from much of its aficionados' online content. To best explain its capabilities to students, we needed to determine what Windows PowerShell is at its core.

Absolute Precision
When we looked at the scripts, the scripting suggestions and the scripting constructs that you can find virtually everywhere on the Internet these days, Jones and I realized that Windows PowerShell's problem is that to the uninitiated it's a scripting language. But, in fact, it's not.

This misperception is not a good thing. Think for a minute about how IT neophytes perceive scripting languages. Solutions like batch, KiXtart and VBScript are all widely considered to be some of the most historically significant Windows scripting languages. While powerful in their own right, for today's freshly minted IT professionals these languages are too complicated, too difficult to learn and a potential source of catastrophe if not wielded with absolute precision.

Their feelings aren't far from the truth. With languages like VBScript, we've all heard the stories of how a few misplaced characters caused a massive deletion -- or of the all-server reboot script that somehow got launched in the middle of the day. VBScript and others weren't without their own security problems, with unprotected runtime environments being automatically installed and listening on every Windows desktop and server.

As a result, entire industries have emerged to create management software that automates the job of the IT professional, all without the nasty scripting interface. For many, the entire process of scripting has become demonized to the point at which it has even been disabled from running in the domain.

Administrative Automation
So, if Windows PowerShell isn't a scripting language, then what is it?

I submit that Windows PowerShell 2.0 is a text-based administrative automation solution. Through the simple connection of a few key cmdlets, even the greenest of IT pros can speed up the completion of the most difficult IT tasks.

Consider, for example, the common problem of adding new AD users and granting them access into one or more global groups. Accomplishing that task using the Windows GUI today requires a set of mouse clicks for each and every user created. Information must be entered multiple times, increasing the chance for error.

Additionally, the time involved to accomplish the task grows linearly with the number of users there are to create. This process is so time-consuming that many of the aforementioned graphically oriented administration solutions have built their own wizards for batch user creation.

On the other hand, consider the elegance of this single Windows PowerShell command:

Import-CSV newusers.csv | New-
ADUser -passthru | Enable-ADAc 
count -passthru | Add-ADGroup 
Member "New Users"

In a single line, this command reads through the list of new users contained within an Excel spreadsheet's .CSV file. It pipes the users it sees to the New-ADUser cmdlet to create those users, then pipes them again to Enable-ADAccount to enable their accounts, and then completes the thread by piping the entire result to Add-ADGroupMember to add their accounts to the New Users global group. Using what's likely the same spreadsheet of users that you've received from your HR department, four commands in a single line have accomplished the task.

That being said, I'll admit that this column's title isn't an entirely true statement. Windows PowerShell indeed comes equipped with some powerful scripting constructs that enable it to accomplish all the tasks you're used to seeing in a scripting language.

But at its very core, Windows PowerShell is something far superior to a scripting language. It's a not-that-difficult mechanism to swiftly accomplish IT's daily tasks, all without the repeated steps and potential for error that accompanies using the mouse.

So, if you haven't yet taken a look at Windows PowerShell for fear of having to learn a new language, give it another chance. You may find that its capabilities are easier and more fulfilling than you think.

About the Author

Greg Shields is a senior partner and principal technologist with Concentrated Technology. He also serves as a contributing editor and columnist for TechNet Magazine and Redmond magazine, and is a highly sought-after and top-ranked speaker for live and recorded events. Greg can be found at numerous IT conferences such as TechEd, MMS and VMworld, among others, and has served as conference chair for 1105 Media’s TechMentor Conference since 2005. Greg has been a multiple recipient of both the Microsoft Most Valuable Professional and VMware vExpert award.

comments powered by Disqus

Reader Comments:

Tue, Jan 29, 2013 Majalah wanita United States

I tried myself and its not applicable and also Powershell is good and also looks nice if you didn't come up in the UNIX.

Fri, Jan 25, 2013 pretty girls United States

I have enjoyed this article so much that I have read it multiple times and plan on coming back for any other articles you may publish.Its not the situation that reader should be totally agreed with author's views about post.

Thu, Jan 10, 2013 Breville bcg800xl Bejo N.

Powershell doesn't run on Windows XP. Most shops are still running XP and are not able to push out the add-on to allow Powershell to run. They should have added this to sp3 for XP. They never bring this fact up in the sales hype. Powershell will not be taken serioulsy until Windows 7 and Server 2008 are the dominate versions.

Thu, Jan 10, 2013 Ambar G.

While I agree PowerSheel seems to be pretty powerful, in my opinion, it is not overly intuitive. I must admit that I have not thoroughly imersed myself in using it, but it seems that syntax and "glueing together" the commands, inputs, outputs, formats, etc... is somewhat foreign. I have been doing DOS batch for over 20 years and have a decent familiarity with Vbscript, C, Basic of a few different flavors, etc... I am sure Powershell is capable, but it seems as though it is such a deviation from most scripting and programming languages that a significant immersion is required to get moving forward with it. It is entirely possible I am just getting old. Signed a "Forty Something"

Tue, Aug 28, 2012 Kids Wall Decals

Sence graphically oriented administration solutions have built their own wizards for batch user creation.

Sat, Aug 11, 2012 green coffee bean benefits

its really good if we know about that.It's running on my XP workstation.

Wed, Aug 1, 2012 Mending Wall Mt Irvine

From my point of view, already knowing some more general purpose languages (Python, Java, Perl, etc), learning a language with a narrower focus is something I just can't get on board with. I do think it's great Microsoft finally after abominations like Batch scripts and VBScript (shudder) has a workable command line interface, and hope people who haven't done much outside of a GUI give it a shot. They'll probably understand things better and get more done.

Thu, May 17, 2012 florist delivery flowers2hawaii.com/florists-in-Hawaii.html

I am really impressed by reading this article. In future, you should be giving information about it more. I must have to admire you for this extra ordinary piece of work.

Mon, May 14, 2012 Nokia mobile prices alaska

I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often....

Mon, May 14, 2012 krill oil benefits United States

I have tried to start learning Powershell on a couple of occasions, but always given up. I think it is because of the lack of "Discoverability" inherent in the Powershell Environment. I have become quite good at programming in Python, because 1, it felt useful immediately, and 2, I could learn it incrementally.

Sat, May 5, 2012 Designer dog harness

Powershell doesn't run on Windows XP. Most shops are still running XP and are not able to push out the add-on to allow Powershell to run. They should have added this to sp3 for XP. They never bring this fact up in the sales hype. Powershell will not be taken serioulsy until Windows 7 and Server 2008 are the dominate versions.

Tue, May 1, 2012 clubmz reviews alaska

Im no expert, but I believe you just made an excellent point. You certainly fully understand what youre speaking about, and I can truly get behind that. Thanks for staying so upfront and so sincere.

Tue, May 1, 2012 clubmz reviews alaska

The above information is appropiate and just what I was looking for. A must read for the layman wanting a brief and precise information. We can do with a little addition of the facts in future.

Sun, Apr 29, 2012 Rogers electricians Rogers electricians

Well content and you took one of the best topic on recent time. Yeah i absolutely agree with you.You make me clear and i surely pleased to read your stuff. The most attractive part was to me that administrative automation here.Thanks for posting. Keep up the good work.

Sat, Apr 28, 2012 argan tree argan tree

I am 20 years old and i still love comics.I agree PowerSheel seems to be pretty powerful, in my opinion, it is not overly intuitive. I must admit that I have not thoroughly imersed myself in using it, but it seems that syntax and "glueing together" the commands, inputs, outputs, formats, etc... is somewhat foreign. I have been doing DOS batch for over 20 years and have a decent familiarity with Vbscript, C, Basic of a few different flavors, etc... I am sure Powershell is capable, but it seems as though it is such a deviation from most scripting and programming languages that a significant immersion is required to get moving forward with it. It is entirely possible I am just getting old. Signed a "Forty Something

Sat, Apr 28, 2012 argan tree http://my.opera.com/jbrisbane/blog/

I am 20 years old and i still love comics.I agree PowerSheel seems to be pretty powerful, in my opinion, it is not overly intuitive. I must admit that I have not thoroughly imersed myself in using it, but it seems that syntax and "glueing together" the commands, inputs, outputs, formats, etc... is somewhat foreign. I have been doing DOS batch for over 20 years and have a decent familiarity with Vbscript, C, Basic of a few different flavors, etc... I am sure Powershell is capable, but it seems as though it is such a deviation from most scripting and programming languages that a significant immersion is required to get moving forward with it. It is entirely possible I am just getting old. Signed a "Forty Something"

Sat, Apr 28, 2012 argan tree http://my.opera.com/jbrisbane/blog/

I am 20 years old and i still love comics.I agree PowerSheel seems to be pretty powerful, in my opinion, it is not overly intuitive. I must admit that I have not thoroughly imersed myself in using it, but it seems that syntax and "glueing together" the commands, inputs, outputs, formats, etc... is somewhat foreign. I have been doing DOS batch for over 20 years and have a decent familiarity with Vbscript, C, Basic of a few different flavors, etc... I am sure Powershell is capable, but it seems as though it is such a deviation from most scripting and programming languages that a significant immersion is required to get moving forward with it. It is entirely possible I am just getting old. Signed a "Forty Something"

Wed, Apr 25, 2012 anti aging http://health-news-for-you.webs.com/

you could have an perfect blog correct here! would you prefer to make some invite posts on my weblog

Wed, Apr 25, 2012 cell phone spying alaska

Thanks for taking the time to discuss that, I feel strongly about this and so really like getting to know more on this kind of field. Do you mind updating your blog post with additional insight? It should be really useful for all of us.

Tue, Mar 6, 2012 ganjar refinishing hardwood floor

I have my powershell on xp, yeah i think so too, its really good if we know about that

Wed, Feb 29, 2012 Josh Munn Jackson, MS

I was never a big scripter before the company I work for migrated from Novell E-dir to Microsoft Active Directory. Now as an AD admin scripting is my best friend. I started with vbscript but many of my coworkers were not used to a non-GUI way of doing things. I then integrated vb with HTML and wrote several HTAs to be more accommodating. I have since transferred many of my vb scripts to powershell. I ran into the same situation as before and had to teach myself windows form language in order to achieve that all so requested GUI. I have never been a programmer and encourage anyone wanting a few more hours of your day back to focus on research or projects to learn this language.

Thu, Oct 27, 2011 Elvena Thinning Hair Women

My opinion regarding IT professional abandoning command line is because there are other type of program with beauty of GUI that is why they prefer to use the better one

Thu, Oct 20, 2011 Event planning certification Event planning jobs

Powershell is fine on my XP, i never heard if powershell doesn't run on XP.

Tue, Sep 20, 2011 Mark J. Canada Zebra Print Bedding

I prefer to choose PowerGUI since its easy to use and also easier to learn. But I don't know which one will perform better

Mon, Jun 20, 2011 Julius D Idaho. kohls printable coupons

It's just like DOS nobody really use it now because command line is hard to remember and it's not efficient. So if you are facing command-line concerns with Powershell, try out PowerGUI. And also Powershell runs fine on Windows XP.

Mon, Jan 10, 2011 Scottalvarino.com Miami

One of the things I like about Powershell is that it automates many of your tasks in windows. Don't learn it to make a website or administer a Unix Server but if you ever use Excel or Administer a Active directory Domain, you will want to have Powershell Version 2 at your disposal to make repetitive and time consuming tasks automagicly done. Check out my scripts at
http://techjunkie.tv
there you will find a few scripts that I use in my daily work life.
Scott
www.ScottAlvarino.com

Thu, Nov 18, 2010 Kari Hardarson Iceland

I have tried to start learning Powershell on a couple of occasions, but always given up. I think it is because of the lack of "Discoverability" inherent in the Powershell Environment. I have become quite good at programming in Python, because 1, it felt useful immediately, and 2, I could learn it incrementally. The focused Tutorial and the dir() and type() commands ensured that I was never stuck. When I sit down to learn powershell, I find myself reading about something I was not interested in in the first place and my interest drops exponentially from there. It's a shame, because I feel I am missing out on something.

Fri, Jul 9, 2010 EricTravers Still right here

re "learning a language with a narrower focus is something I just can't get on board with" <- Narrow focus? With the entire .net framework at your disposal? I am not going to try and insult you. You are obviously an intelligent person, but I think you should reevaluated Powershell before you dismiss it as limited.

Fri, Jul 9, 2010 EricTravers Right Here

Powershell is just what the name says. It's a shell. You can use it all day every day without ever writing a script. Like any other shell it is scriptable. DOS has .bat, on Bash I have .sh and on Powershell I have .ps1. That being said; Powershell is very scriptable. The thing is you don't have to start by learning a scripting language. I started using it instead of running cmd and picked up bits and pieces as I went along. I've been using it for about 1.5 years. I have maybe 5 scripts. I am getting to the point where I find myself running some of the same commands repeatedly. Instead of being a trained monkey I just put it all in a file and let it run itself. Just like with any other shell you are not going to come to the office in the morning and type in the same commands every day. If you do something repeatedly you script it. It's common sense. There are some BMFs out there that write scripts that will blow your mind. I read their code and I am awed. That's them. Maybe someday I will get to that point, but for now I love having an interactive shell that blows DOS out of the water.

Fri, Jul 9, 2010 SDC

I can see where Powershell is nice and maybe even looks amazing if you didn't come up in the UNIX environment. From my point of view, already knowing some more general purpose languages (Python, Java, Perl, etc), learning a language with a narrower focus is something I just can't get on board with. I do think it's great Microsoft finally after abominations like Batch scripts and VBScript (shudder) has a workable command line interface, and hope people who haven't done much outside of a GUI give it a shot. They'll probably understand things better and get more done.

Wed, May 12, 2010

While I agree PowerSheel seems to be pretty powerful, in my opinion, it is not overly intuitive. I must admit that I have not thoroughly imersed myself in using it, but it seems that syntax and "glueing together" the commands, inputs, outputs, formats, etc... is somewhat foreign. I have been doing DOS batch for over 20 years and have a decent familiarity with Vbscript, C, Basic of a few different flavors, etc... I am sure Powershell is capable, but it seems as though it is such a deviation from most scripting and programming languages that a significant immersion is required to get moving forward with it. It is entirely possible I am just getting old. Signed a "Forty Something"

Tue, May 11, 2010 April Illinois

Powershell runs just fine on my XP- no hype necessary

Tue, May 11, 2010

Powershell doesn't run on XP? It's running on my XP workstation.

Sat, May 8, 2010 Larry Connecticut

As an IT person with 35 years of experience, the last ten managing desktops for 2,000 people in 100 different locations across the US, I would not want one of your "newly minted IT professionals" working on my network if they think things like VBScript, WSH, KiXtart, etc., are too complicated or too difficult. The issue with scripting isn't that it's that difficult it's that today's IT professional is too lazy to learn the set of tools that are needed in today's IT environment. I am tired of spoon feeding these so called professionals. No, I never caused any massive deletions of anything in all that time. It's called attention to details and testing.

Tue, May 4, 2010

Powershell doesn't run on Windows XP. Most shops are still running XP and are not able to push out the add-on to allow Powershell to run. They should have added this to sp3 for XP. They never bring this fact up in the sales hype. Powershell will not be taken serioulsy until Windows 7 and Server 2008 are the dominate versions.

Mon, May 3, 2010

There are actually a number of reasons why admins aren't running to Powershell. In small to medium sized businesses, the time saved by using Powershell is often less than the time required to learn what is essentially another language. In the last decade, I could count on one hand the number of times that I have had to add more than two users to AD at once. Even then, the users belonged to different groups. I'm sure that things are different when you have thousands of users. Another reason is that most admins already have a number a scripts for tasks that were worth automating in their environment. If it ain't broke... The last reason that I am going to mention is that most IT people have enough new things to learn every day and Powershell just doesn't make the cut in the priority list. I have wanted to learn Powershell for a number of years but it falls under what I want to learn vs what I have to learn. When you are a generalist you not only have to learn new features for a multitude of programs and technologies, you also have to re-learn all of the old stuff that has changed. I think change is great when there is a benefit. When change is made solely for marketing purposes, that is another story. Unfortunately, most changes fall under the latter category.

Add Your Comment Now:

Your Name:(optional)
Your Email:(optional)
Your Location:(optional)
Comment:
Please type the letters/numbers you see above

Redmond Tech Watch

Sign up for our newsletter.

I agree to this site's Privacy Policy.