Ezine 159 – PowerShell, PowerGUI and QaD
PowerGUI, as the name suggests, provides a graphical method for scripting with PowerShell. The idea is to control your operating system by clicking on menus with the mouse, rather than typing commands in a shell. What QaD does is provide extra ‘handles’ for PowerShell to manipulate Active Directory objects.
As you read this article, please keep in mind two points; firstly I have no connection with PowerGUI or QaD, secondly, these utilities are available as free downloads.
Topics for PowerShell, PowerGUI and QaD
- This Week’s Secret
- Benefits of PowerGUI
- This Week’s Mission – Ambidextrous Scripting
- Getting started with PowerGUI
- PowerShell New-AdUser
- QaD Snap-ins
I wish that I was more ambidextrous. Heavy duty mouse work causes the fingers on my right hand to ache; when this happens I switch the mouse to my left hand. Swapping the mouse between hands leads me to think of PowerGUI; the link is the way this utility encourages ‘ambidextrous scripting’. What I mean is with this free utility you can click on objects in the GUI with the mouse, or else you can switch to the command line and manipulate the same objects with instructions from the keyboard.
To digress, I wonder whether ambidexterity is prized in American sports. We Brits try and kick the ball with either foot in both rugby and soccer, and we certainly try to catch with either hand in cricket. Yet in baseball, or NFL there does not seem the same need for using the ‘other’ hand.
PowerGUI reminds me of ambidexterity because people fall into two main camps; those dexter (right-handed) types, who operate only with a mouse inside a GUI, and those sinister (left-handed) types, who use only the keyboard inside the dark world of the command-line shell. Now, if you master PowerGUI you are going to employ both GUI and shell and thus enter the world of ‘ambidextrous scripting’.
Ah yes, the benefits. With PowerGUI beginners can create complicated scripts with little knowledge of the underlying PowerShell commands. Yet, I think it’s the intermediate scripters who benefit the most from getting the free PowerGUI. They know enough to make sense of the code, moreover, they are curious enough to add their own extra commands. Gradually, intermediates find that adapting a PowerGUI script at the command line is faster than repeating the more laborious steps of clicking in the GUI to create another ‘Filter’. In no time at all, intermediates develop into experts, or would that be, expert into developers!
Killer Reason to Get QaD Snap-ins
QaD (Quest Active Directory) snap-ins are a very useful in their own right. The reason for downloading these free QaD snap-ins, with their cmdlets, is because PowerShell has so few native Active Directory commands. Also keep in mind that PowerGUI can script files as well domain objects. My point is when you bring PowerGUI and QaD snap-ins together, the whole is greater than the two halves.
Persuading people to try PowerGUI is a classic example of my main role, getting people started with PowerShell. Describing PowerGUI is easy because this is such an intuitive, and well designed package. My hardest task is convincing you to take action and actually download and install PowerGUI and also QaD. Hopefully, even that won’t be too difficult.
This concept of ‘ambidextrous scripting’ also complements my master plan of using the GUI to learn about PowerShell, and scripting with PowerShell to control what you see in Windows Explorer or Active Directory Users and Computers.
Download PowerGUI and QaD Snap-ins from these sites:
Finding the correct site is a no-brainer for some, easy when you have been there once; tricky for the complete beginner. Here are the URLs:
Pre-requisite. You have already downloaded PowerShell from Microsoft’s site, and installed it.
Installing PowerGUI is easy – Guy applauds their developer team. What impressed me was the way my PowerGUI program intelligently checked for, and found, a newer version, which it then installed automatically. Just one click on the ‘Agree to licence’ button, and no requirement for a reboot.
Once you have installed PowerGUI, my crucial role is to help newbies make the relatively simple connection between the GUI and the Shell (PowerShell command line). This is a knack; you just need to know three things to get started.
1) Filter – Find the funnel symbol at the very top of the PowerGUI screen. Creating a filter is a matter of clicking on three column headings: ‘Property’, ‘Operator’ and ‘Value’. (Note: Save As.. facility)
2) Seek two tabs low down at the bottom of the screen; the first tab says ‘UI’, the second tab says: ‘PowerShell Code’. Enjoy the output!
3) One more thing, you may have already spotted a ‘tree’ on the left of the PowerGUI. And just like Windows Explorer, you can select drives in this ‘tree’ before you click on ‘Filter’. I would like to point out that if you install the QaD snap-in, with its extra cmdlets, you will see Active Directory objects in the ‘tree’.
Orientation: Naturally you need to connect to domain to gain maximum effect with this technique. For instance, I installed PowerGUI, QaD and PowerShell on a Domain Controller. If you just install PowerGUI on XP with no PowerShell, no QaD and no Domain, you are going to be a little disappointed.
Guy Recommends: The Free IP Address Tracker (IPAT)
Calculating IP Address ranges is a black art, which many network managers solve by creating custom Excel spreadsheets. IPAT cracks this problem of allocating IP addresses in networks in two ways:
For Mr Organized there is a nifty subnet calculator, you enter the network address and the subnet mask, then IPAT works out the usable addresses and their ranges.
For Mr Lazy IPAT discovers and then displays the IP addresses of existing computers. Download the Free IP Address Tracker
This is how I see it, PowerShell has zillions of built-in cmdlets, but not many for Active Directory. QaD created half a zillion specialist Active Directory cmdlets and ‘packaged’ them into a Snap-in. Our missing link is to install that QaD snap-in. Furthermore, it’s worth getting the QaD cmdlets whether you use PowerGUI, or script only with the PowerShell command-line shell.
Unless you have a passing familiarity with PowerShell installing the snap-in (some call them snapins) is tricky. Assuming that you have downloaded the package from QaD, here below is the PowerShell command. What I don’t know – but you do, is where on your machine you downloaded the QaD file. My point you need to edit c:\ in the command below.
# Instruction to add a Snap-in
Example of QaD Active Directory cmdlet
Here is an example of a QaD (Quest Active Directory) query. This the crucial part of what the PowerShell Code button displays. The ‘Filter’ was: City (Property) Equal (Operator) Birmingham (Value).
Perhaps you can see how easy it would be to change the value of "Birmingham" to "Boston". After a few tries, you may discover how straightforward it is to change the property .City to .Department, .Company or .Description.
Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.
It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.
Summary of PowerGUI and QaD
If you are committed to learning PowerShell, but struggle with some of its syntax, then PowerGUI is an ideal tool to help you learn to write better scripts. Use PowerGUI like a metaphorical slider. Click the UI button to lean towards pure mouse and menu driven methods. Click on PowerShell Code to slide into regular command line scripting.
Even PowerShell experts struggle to script Active Directory objects. Even experts cheat and download QaD snap-ins. Guy says, ‘Let’s follow the experts and take advantage of QaD’s expertise’.
If you like this page then please share it with your friends
See more PowerShell QAD Scripts
Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.