«

»

Feb 08

Teaching an old dog new tricks. Using PowerShell to make life better.

PowerShell has been around for a while now and I use it quite a lot. I’m a programmer so I like to be able to run scripts with loops etc so I get excited that using PowerShell I can display my 8 times tables with this code:

foreach ($num in 1..12 ) { $num * 8}

I also like using the keyboard so am quite happy diving into PowerShell rather than using a GUI. Dave on the other hand is not at all bothered that he can easily solve maths problems, he also often jokes that “it’s called Windows – not typees”. This results in much banter in the office with me often saying that “you could do that in PowerShell” and Dave ignoring me.

I finally thought something had to be done when Dave was installing SharePoint 2010 and FAST search. He had to restart the FAST services. This resulted in a lot of clicking, waiting and more clicking. Time for me to step in with the ever helpful comment of ‘you could do that in Powershell!’.

Dave is not afraid of code views and is often seen firing up a cmd prompt to ping a server or perform an iisreset so I needed to demonstrate how powershell could make his life better and not be something to avoid. I started with ISE.

The Integrated Scripting Environment (ISE) is, in my opinion, is the way powershell should be used. It’s all part of the default PowerShell stuff you get on a normal install of Windows 7 or the like.

With this you get a Notepad style area to write you code (well formatted and colour coded). This also has multiple tabs so you can work on several things at once. There is no point me trying to explain how much easier this is to use than just the powershell window, you need to try it out and see.

The other thing I pointed out to Dave was how easy it was to restart services on a server. So for all thoes SharePoint 2010 FAST services;

Restart-Service -displayname FAST* -whatif

Just like that. The -whatif switch just outputs what will be done, remove the switch and the command will run. So I can run  this code without fear of my browser closing!

From the ISE the commands can be saved, ready for use next time.

Go on, give PowerShell a chance, you’d be barking mad not too.

About Chris McKinley

Chris McKinley has written 26 post on this blog.


Technorati Tags: ,

No related posts.

1 comment

  1. scraper

    Have you ever considered adding more videos to your blog posts to keep the readers more entertained? I mean I just read through the entire article of yours and it was quite good but since I’m more of a visual learner,I found that to be more helpful. Just my my idea, Good luck

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>