Now, sure, just like you start to remember familiar DOS commands or even Bash commands in Linux or Unix, you'll remember some things if you use them often enough. But PowerShell's help and the examples that you get right out of the box with no further effort (other than to update the help files as I recommended earlier) will always be there as guides to help you figure out what's going on and how to work your way out of a puzzle.
Something practical
We have covered only the very, very basics here, but let's do something practical before we close up this piece so that you get a real feel for PowerShell and can practice what you read here right away.
Two very common things you do in administering systems are finding processes and killing them. You might currently use Task Manager, or for more detailed work you might use the DOS command tasklist /svc to find the process ID for a given service and what it’s running, and then use Task Manager to kill it. With PowerShell, we can do the same thing.
Let's say that -- purely hypothetically, of course -- we have a browser whose name rhymes with Moogle Shrome. It is not well behaved and sucks up a ton of memory if you leave it open overnight. (As mentioned, this is absolutely hypothetical.) We need to find it and kill it before it does more damage.
You can probably guess how the cmdlets for working with processes would work. Get-process will get a list of processes that are currently running on your system, formatted as a table by default.
PowerShell's Get-process cmdlet.
I know from get-help get-process that I can specify the name of a process that will display information only about that process:
Using a PowerShell cmdlet to get information about a specific process.
And I'm thinking that if get-process gets me the information about a process, then using the verb-noun format, stop-process would stop one. (I could always check this out using get-help or get-help examples, but since I'm a in a hurry, I proceed without reading the directions and just assume that this cmdlet exists.)
PowerShell's stop-process cmdlet.
My brazenness is rewarded! But now it's asking me for an ID because when I entered the stop-process cmdlet, I didn't tell it which process to stop. I could scroll up and look for the ID in the results table from get-process chrome. Looks like process ID 2924 is taking up a lot of CPU time, so I'll enter 2924 and hit enter.
If that's the only one I want, I hit Enter again on a blank line. (PowerShell is assuming there might be more than one ID I want to kill and is letting me enter multiple IDs at one time, but to skip out of this anytime you see this, simply enter a blank line.) I immediately note that Googl...ahem, Moogle Shrome has disappeared.
Without the handholding, I could have accomplished the same thing using this sequence:
Get-process
Get-process chrome
Stop-process 2924
And I'd be done.
Wrapping up
Congratulations! We just used PowerShell to kill a process that had gone awry. We puzzled our way through cmdlets, used parameters, remembered ways we could find out related cmdlets and successfully made educated guesses about whether certain cmdlets existed by remembering the verb-noun naming methodology.
Now you have the tools to make a good start at using PowerShell like a pro.
This story, "Getting started with PowerShell: The basics" was originally published by Computerworld.