PowerShell is quickly taking over IT departments and with such big names behind it, it’s no wonder. If you already use PowerShell, chances are that you have used a module or snap-in from one of the companies below:
For those not familiar with PowerShell, when they see how quickly or easily things can be configured or automated, they of course want to get in on the action. So how do you go about introducing someone to PowerShell and make them self-sufficient? You give them a link to www.ScriptingGuys.com and tell them to study up. But what if I am giving them an in-person demo? I show them my guide to using PowerShell for the first time and then usually start out with these five* commands:
The first thing that people usually want to know is, ‘What can I do with PowerShell?’ At that point, I load up the console and tell them to type in Get-Command. A long list of available cmdlets starts scrolling by and you can see their eyes light up. Once they find a cmdlet that interests them (there always is and most of the time it has to deal with a current issue they are facing), I move on to the next command.
This is my go-to command; I use it more often than any other. If I ever come across a command that I want to use, but don’t know how, Get-Help is my first stop. To see more details for a cmdlet, you can use one of the following:
I’ve found that the –Examples switch is the best for beginners, as it gives them an idea of what can be done with the command and lists the information that they need to accomplish the task. With these two cmdlets, they have more than enough to get started and get some work done. Once they have had a little bit of practice, I continue on with where it gets really interesting, modules!
Get-Module / Import-Module
As with most IT professionals, you and the trainee have probably worked with a technology from at least one of the companies listed at the beginning of this post. Did you know that they all provide PowerShell modules or snap-ins that help you automate their products? To view all modules that are available on your machine, just type Get-Module –ListAvailable at the PowerShell console and you should see a list of each one available and the commands included. If you were looking for one of the modules from a vendor listed above, be sure to download and install it first, then re-run the Get-Module cmdlet. Once the modules are installed, you can import them using Import-Module
. Now you can use the commands you learned previously to view each of the cmdlets available in the module and their usage:
Note: Some of the vendors are still providing their cmdlets in snap-ins, which is legacy for PowerShell v1.0.
Get-Member or Format-List
At this point, the trainee should have a general understanding of what PowerShell is and how to use it. Depending on the background of the person, I tailor the last section for their professional background. For anyone with a developer background, I typically show them Get-Member, as it shows them all of the methods, properties and other membertypes, which they are familiar with seeing. For the IT Pros learning PowerShell, I typically stick with Format-List. This gives them the information system administrators and technicians are looking for and when they are more comfortable, I loop back and show them Get-Member.
And that wraps up my beginner’s guide for PowerShell. You provide the who and why and I provide the what and how. ‘When’, you say? The time for PowerShell is NOW!
Post a Comment