A Simple Answer to "Where Do I Start?" in PowerShell
Whenever I speak to a new group of PowerShell students, one of the first questions that comes up is, "where do I start?" The question really has two versions: "Where do I start learning PowerShell," and "Where do I start when I'm trying to accomplish (insert your administrative task here)?" PowerShell is still fairly new, and it can seem pretty intimidating - especially if the examples you've seen so far have been of the super-complex variety. I have a simple answer to both questions, though.
June 16, 2010
I'm teaching a class this week to some great students in Providence, RI, many of whom are using PowerShell for the first time. That's the inspiration for today's post.
Whenever I speak to a new group of PowerShell students, one of the first questions that comes up is, "where do I start?" The question really has two versions: "Where do I start learning PowerShell," and "Where do I start when I'm trying to accomplish (insert your administrative task here)?" PowerShell is still fairly new, and it can seem pretty intimidating - especially if the examples you've seen so far have been of the super-complex variety. I have a simple answer to both questions, though.
Before I start, though, do me a favor: Think of every coworker, peer, and colleague that you know who has resisted learning PowerShell, and send them a link to this, okay? Let's start getting the word out.
Let's tackle the first: "Where do I start learning PowerShell?" The answer is NOT - surprisingly, especially coming from me - to go buy a book, or a training video, or even to start spelunking in Google or Bing. Instead, just start USING the shell. Take the simplest kind of task you can imagine - perhaps moving some files and folders, or perhaps creating a new AD user - and figure out how to do that in the shell. It's rarely difficult: PowerShell works similarly to the copy, cd, dir, and other file system commands you're probably already used to. Yes, they work a bit differently - and running "help dir" (or whatever) will help you figure out how to use the new versions of these commands. The point is to get out of "GUI mode" and into "shell mode" for these simple tasks.
A caution: If you're not willing to read the in-shell help, you're probably going to struggle a lot, and very likely fail to become effective in the shell. For example, "dir /s" won't work to list directories and their subdirectories; the new dir command is slightly different. Read the help, though, and I promise you'll see the new version of the /s parameter.
As you become more comfortable, start looking for new tasks to perform in the shell. Use the help command to search for new commands: "Help *process*" will help you find help and commands related to managing processes, for example. Run "dir $pshome/modules" on your client and server computers to find add-in modules that offer additional functionality; running "Import-Module modulename" (with the right module name) will load a new module into memory, and the Help command can help you learn about those new commands.
Two tips:
First, if you're searching the Web and find some example that looks crazily complicated - ignore it. At least in the beginning. PowerShell supports a variety of different user levels, and just because you've found something at the high end of complexity doesn't mean a less-complex approach isn't available. A lot of what's online tends to be posted by my fellow MVPs, who are major PowerShell enthusiasts, and who often work at a way higher level than a beginner would. But they all STARTED as beginners - they just didn't post a lot of examples from then.
Second, if it looks like you can't accomplish something in PowerShell without going into super-complexity mode, just forget about it for now. Use the GUI like you always have, if you don't have time to pursue it further. Over time, though, you'll learn more tips and tricks, and you'll revisit those harder tasks and start looking at how to PowerShell them.
Now for the second question: "I want to accomplish 'x,' so where do I start?" This is, actually, pretty straightforward once you figure out how PowerShell thinks. First, identify the nouns that you want to manipulate: Users, files, processes, services, whatever. Then, hit a search engine with that noun, combined with the PowerShell keyword: "PowerShell AD User," for example, or "PowerShell File Permissions." Lightly scan whatever examples you find to locate the commands being used in them - PowerShell commands all have a naming convention of "verb-noun," such as "New-ADUser" or "Get-ACL." Then, read the built-in help on those same commands. Start from there to accomplish your task. Remember, adding "-example" to a help command (like "help new-aduser -example") will show built-in examples.
Still stuck? Go to WindowsITPro.com, hover over the FAQ item in the top-of-page menu, and select the option to submit a FAQ for Windows PowerShell. I'll get your submission and do my best to help! You can find a full list of FAQs on my PowerShell home page.
About the Author
You May Also Like