Tuesday, April 10, 2012

PowerShell is about doing things not writing scripts

With PowerShell finally going cross-platform with Windows 8 I keep hearing the same comments over and over – “just write a script for that”

You know what?  Not everything needs a script.  A few commands maybe, but not a script.

Why do I bring this up?  Because script writing is intimidating.  You have to understand loops, arrays, object types, schemas, properties, and other developer-type things.

But if you only have a make a couple modifications to settings, every so often or discover something.  You don’t need a script for that, you need some commands.

And this is where the lingo and the action are becoming disconnected. 

If you look at it one way, PowerShell is to Windows what BASH is to Linux and what Command was to DOS.  A way to get things done.  A place to find things and do things.

Did everything that you did in DOS have to turn into a BATCH script?  No.  But back in the day we did write some pretty complex user logon and logoff scripts.  Why?

Because certain tasks needed to be repeated over and over.  That is where we need a script over a few captured commands.

My other big gripe is script or command examples.  Folks that blog some long and highly complex one-liner that is very difficult to comprehend because you get lost in the pipeline.  The big disservice being that they never do it long hand.

Most folks that I encounter these days are either at the 100 level of using PowerShell or at the 300 – 400 level.  You just straight through the 200 level when you write a script or suddenly grok objects.


Devon Schreiner said...

I like what you're saying. I am definitely not a script type person. But of course, we fall into the category of writing scripts for everything here but I think it's almost as much for documentation rather than repeating a process. Now we can go back and see exactly how we set that server up or where we put that config file.

Anonymous said...

I agree totally.

I'm in, but I can see why people shy away. If your exposure to PowerShell is the dense 500line script that uses .NET assemblies, you may run the other way. I like it for some of the quick adhoc stuff you can do.
Doing things consistently through scripts is good, too. When I set up XenApp server templates, I use the ServerManager module to do the roles and features (for starts).