Using GUI to script PowerShell with PowerGUI
Recently I was watching the new Train Signal vSphere Pro video training course covering using PowerCLI and PowerShell with VMware vSphere. This course is taught by Microsoft PowerShell MVP, Hal Rottenberg (of TechProsaic.com). From this course, I learned a lot about PowerShell and was excited at the thought of being able to create some myself. Sure, you can just run the PowerShell command prompt in Windows. That is easy to do but, to any new user, it is very intimidating. Recently, I came across PowerGUI, a graphical PowerShell Editor and that is what I will be covering in this article.
Why do I need PowerShell?
If you are new to PowerShell you may still be asking what it is and why you need it. These are easy questions to answer and I am confident that you will see the obvious usefulness of PowerShell once it's explained.
According to WikiPedia, PowerShell is an "extensible automation engine from Microsoft, made up of a command-line shell and associated scripting language". It's built on top of .NET and it is used to perform administrative tasks on local and remote Windows systems. Those administrative tasks could be related to Windows network management, Active Directory, Hyper-V, or even 3rd party programs like VMware (if those programs support it). These administrative tasks can be automated to run at specific times or be initiated from other applications to perform some task.
To me, the cool thing about PowerShell is that it can be used across so many different Windows OS features and supported 3rd party applications - allowing you to control and manage your entire Windows server (both OS and apps).
If you are running Windows 7, PowerShell 2.0 is already included and installed. Prior to that OS, you will need to install it from the Microsoft Script Center homepage.
In Windows 7, just go to the Start menu, Administrative Tools, then to Windows Powershell Modules. You will see your PowerShell command line that looks like this:
Figure 1: PowerShell CLI
While that is "nice" and the way that most admins use PowerShell this command-line interface can be daunting for those new to PowerShell or even new to any kind of command line interface.
The answer is PowerGUI.
What is PowerGUI and how can it help me?
Before you think that I am trying to sell you some kind of commercial tool here, let me first tell you that PowerGUI is completely free, as are their PowerGUI libraries and community forums.
PowerGUI can help you by:
- Allowing you to run PowerShell scripts with NO scripting knowledge
- Allowing you to see the scripts that PowerGUI creates for you so that you can understand PowerShell and by allowing you to export those scripts (which you could modify and turn into your own scripts)
- Provides a way to add "PowerPack Libraries" so that you can extend this functionality to 100's of other applications and/or Windows features (see Figure 2)
- Offering an intelligent PowerShell script editor to make script editing easier (see Figure 3)
Figure 2: Extend PowerGUI with PowerPacks from the Library
Figure 3: PowerShell Script Editor
So where do you get it and how do you install it?
Downloading and Installing PowerGUI
The 8MB PowerGUI can be found at the PowerGUI download page. As you can imagine with an application that size, the download and installation are very fast.
Other than all the standard installation questions, there is just one point in the GUI that you need to take note of - the Features Install. During this point in the install (before in Figure 4), you have the chance to specify what PowerGUI features you want installed.
Figure 4: PowerGUI Features Selection
This includes PowerPacks like Exchange 2007, Active Directory, and Network. While Local System and Network are checked by default, the other two I mentioned are not.
Just before the installation completes, you can say that you want PowerGUI to start automatically when the install finishes. Here is what PowerGUI looks like when it is first started:
Figure 5: PowerGUI Initial Startup
That's much less intimidating that the command prompt I showed you above, isn't it?
Honestly, thus far in my PowerShell education, I am just getting started but with just a little clicking-around, I was able to browse to the user list on my local computer and see what users are currently added. By going up to View, then down to PowerShell script, a new tab was opened that showed me the PS that is executed for anything that I did. It is in this window that I could take the PS for the common tasks that I perform and easily create automated scripts, even without really knowing much of anything about how to use PS. Here is what it looks like in Figure 6:
Figure 6: Viewing PowerShell scripts that are being run
Even though I have had extensive experience creating and editing Unix/Linux shell scripts and limited experience programming, it is always nice to have a GUI tool to help you get started when you are learning a new language.
I am pleased that I found the totally free PowerShell tool - PowerGUI. I like it because it helps you to 1) run PowerShell scripts without knowing PowerShell 2) helps you to understand PowerShell by showing the scripts that are generated from your actions in the GUI 3) Allows you to extend this functionality to so many Windows apps (both internal to Windows and 3rd party), and 4) helps you to edit PowerShell scripts and export their results. If you are interested in learning PowerShell, I do recommend you try out PowerGUI.