31 Days of Our Favorite Things: Feel the Power of PowerShell 3.0 (Part 3 of 31)

imageI thought long and hard what would be my favorite thing of Windows Server 2012.  Yeah, right who am I kidding, I thought for about 5 seconds what my first post of this series would be. PowerShell, it always was going to be PowerShell and it should not have surprised anyone.  Especially after the book Sarah and I wrote.  I have to tell you I never thought anything would beat PowerShell 2.0, and yet I was so wrong.  Along came PowerShell 3.0, and I was simply blown away.  Here are two numbers to start our conversation to put PowerShell 3.0 in perspective

  • 230
  • 2,430

The first number 230 is approximately, the amount of cmdlets in Windows Server 2008 R2.  That is right in Windows 2008 R2 all the power you had in PowerShell boiled down to about 230 cmdlets.  The second number is approximately the total number of cmdlets in Windows Server 2012.  That is right the 2,430 cmdlets represents a 10X increase in the cmdlets and in the Hyper-V role alone there is ~163 cmdlets alone.  So as you can imagine we can do even more with Windows Server 2012.  Learning PowerShell is the key to managing and automating your servers in your datacenter.  It is very important to start learning the language and if you have not, check out the series Sarah and I wrote in May 2011.  This will help you started.  While some of the cmdlets may be slightly different,  the foundation we provide in the series will get you started down the path of learning this wonderful language.  Check out the series here:

PowerShell Not your Father’s Command Line 31 Days of PowerShell

Here are a two of my favorite additions to PowerShell 3.0, I kept it to just two, otherwise this post may never end.

  1. PowerShell History
  2. Integrated Scripting Environment (ISE)

PowerShell History

Some of you may be familiar with the Active Directory Administrative Center (ADAC).  The ADAC allows you to do all kinds of Active Directory tasks in a very friendly interface.  Depending on your level of pshellhistAD knowledge this tool may or may not have been for you.  However for the average administrator you could search for users, reset passwords, work with AD objects (users, groups, OU’s …etc.) very easily.  It is a tool that can save you time.  The tool is built on PowerShell in Windows Server 2012 and has gotten some fantastic enhancements.  One of the key enhancements is the PowerShell History Viewer.  This tool provides you x-ray vision to the ADAC tool.  You can see under the covers, and see the actual PowerShell commands that were executed when you performed a task in the ADAC GUI.  What I really like about this feature is it allows quickly learn the syntax for working with Active Directory cmdlets.  This will allow you to quickly reverse engineer common AD PowerShell scripts and turn them into your own scripts.  A word of note the PowerShell history is cleared when you close the ADAC.

 

You can read more about the Windows Server 2012 ADAC here: Introduction to Active Directory Administrative Center Enhancements 

Integrated Scripting Environment (ISE)

pshellcommandThe ISE actually has two additions that make learning and writing PowerShell scripts event easier.  The first enhancement to the ISE is something I am sure all developers and IT Pros are anxious to have: IntelliSense.  Yes you read that right PowerShell has included IntelliSense.  This feature is very similar to the drop down support in Visual Studio and allows to write PowerShell commands. IntelliSense provides support for properties, methods, cmdlets names, function names and even parameters, all via a drop down list.  Very handy to make sure you have your cmdlets properly written.

The second thing I really like in the ISE is the command add-on.  This is a new pane that allows you to quickly find and create PowerShell cmdlets in dialog box style interface.  The pane should be visible by default, if it is not, you can open the command add-on via the view menu in the ISE.  You filter your commands by category and scroll through the list until you find the cmdlet your looking for.  When you select cmdlet you can then click the Show Details and it will show you all the parameters for the cmdlet you are currently looking at.  You can than fill in all the values for the parameters in the cmdlet, and when your done you can either click insert or copy.  When you click insert it will place the completed cmdlet in the console pane and you can than execute the cmdlet.  If you click copy, it places the cmdlet on the clipboard, where you can paste it into the script pane or other PowerShell editing tool.  This really exposes all the parameters for cmdlets and make sure you having Powershell do all it can for you.  Additionally the command add-on will allow you to include the common parameters.  Simply Amazing!

I could go on and on about PowerShell 3.0.   have only touched on just a couple of my favorite things, there even may be enough for another series. ….mmmmmh now that sounds interesting Get-NewSeries –PowerShell

Resources

You can take PowerShell 3.0 for a test drive in Windows Server 2012, by checking out these downloads:

If you missed any of the parts you can find the rest of the series here: 31 Days of Our Favorite Things in Windows Server 2012.