Register. Track Progress. Earn Credits.
Learning has never been so easy!
Sign Up

One preconception a lot of IT pros have about PowerShell is that it's some form of arcane sorcery. There's all the commands, a language that's unique unto itself, and scripts that sometimes seem like bizarre incantations. PowerShell MVP and IT consultant specialist Jeff Hicks wants you to know that, if you're among those with such preconceptions about PowerShell, you're wrong. 

"PowerShell is easier to learn than most people realize," Hicks writes in a guide on learning PowerShell for Petri. "PowerShell is a mechanism for working with the things that you want to manage." It's a pipeline to the inner guts of your computers and servers – the outcome you want begins with the verb-noun command structure. And when you think about it that way, it gets a lot easier to learn. 

Hicks advises thinking of PowerShell as a "virtual assembly line ... [where] the end result is a pipelined expression that you can type interactively." He starts with a basic command: 

Text
Get-Service | Where {$_.status –eq 'running'} | sort Displayname

Get-Service is your first step. Think of it as a bucket, Hicks advises. By itself, the command would retrieve all services on your computer. But that's not useful; you want to see what services are running. So you pass the bucket down the assembly line and, at its next stop, you enter a command that throws out all the services that are inactive. But that's still just a jumbled mess of services. Once more, you pass the bucket down the line, and sort everything inside by alphabetical order. And presto, you've done it. 

"Now, if you wanted to use this as the basis for a more complicated command to build a report of mission critical running services on 100 servers and email the results as an HTML report, this process will take several steps," Hicks writes. But it's possible. And while it might feel like a game of MouseTrap, it's game you don't have to play by yourself. There are tools and resources, as well as repositories of preconfigured scripts out there that others have built.

The key to learning PowerShell ... is learning how to use PowerShell

But the key to learning PowerShell is to understand that you can't learn PowerShell. You can learn how to use PowerShell, which is a significant difference. With over 3,000 commands out there and scripts immeasurable, PowerShell is a constantly evolving beast and, no matter what someone tells you, it's just as impossible to learn every single PowerShell command and scripting function as it is to learn every word in the English language. 

What you can instead do, Hicks advises, is consult free eBooks on PowerShell, consult YouTube channels that get it right, such as Hicks' own and others, and then put that knowledge to the test every day. The next time you have a problem, or task, you want to solve, try using PowerShell. And in that regard, there are two commands that are immeasurably helpful: 

Text
Get-Command -Module Microsoft*,Cim*,PS*,ISE | Get-Random | Get-Help -ShowWindow

Get-Random -input (Get-Help about*) | Get-Help -ShowWindow

The first pulls a cmdlet at random from "the core, out-of-the-box PowerShell, and displays the help for that cmdlet in a popup window. The second does a similar thing for one of the concepts about topics." And if you keep up with it, you'll see that PowerShell isn't some arcane sorcery. Unless, of course, you want it to be. 


Difficulty Level: Beginner
Tagged in:
Mini magick20170804 32840 vsyg6y profile
SpiceworksStaff WriterAustin, TX3 years in IT
Voice of IT Champion Scottish Flag Challenger Level 3 Challenger Level 2


Main Areas of Contribution:
 

21 Comments

Mini magick20141013 25299 n9gsb0 big
Datil
mattmcnabb
The key to learning PowerShell ... is learning how to use PowerShell

But the key to learning PowerShell is to understand that you can't learn PowerShell. You can learn how to use PowerShell, which is a significant difference. With over 3,000 commands out there and scripts immeasurable, PowerShell is a constantly evolving beast and, no matter what someone tells you, it's just as impossible to learn every single PowerShell command and scripting function as it is to learn every word in the English language.

This is a good point. In the old model of command line administration you would have to learn how to use each utility (command) and it's own intricacies. Each utility had its own model and was developed independently of any other utilities so there was very little consistency. From an architecture standpoint, there was very little effort devoted to the shell itself and all the effort was in the utilities.

The Powershell model is much different. Tons of effort have been poured into architecting the shell so that developing commands (cmdlets, functions) is easy and has a strict-ish set of guidelines. This means that commands can now work together and you get expected behavior no matter what underlying technology you are managing. So now you are learning behavior rather than memorizing commands and switches, and Powershell helps you find all the details of for the technologies you are managing.
Mini magick20150924 10791 11dn6cv big
Poblano
adambertram

I'd add to not be afraid of asking for help.  As a newcomer to PowerShell (or to any new language) it may seem daunting especially if you don't have kind of programming/scripting background.  Ask for help here in the Spiceworks forum, powershell.org or even on Twitter.  We're here to help in any way we can.

Mini magick20140312 12789 zb6m98 big
Datil
MKarmil

The MVA got me started and I swear by it for beginners. Great tool to have now that I learned the language. It doesn't take much, and after you spend some time using it, it just makes sense.

Mini magick20160129 13173 a7p1ww big
Poblano
thebluejakel

If it's a type of arcane sorcery then its a good thing I'm a half elf sorcerer.

Mini magick.6039.221325 big
Thai Pepper
dpaul

MKarmil wrote:

The MVA got me started and I swear by it for beginners. Great tool to have now that I learned the language. It doesn't take much, and after you spend some time using it, it just makes sense.

I agree.  I did the MVA videos and stuff and it makes sense now.  I don't use it very often, but it is very handy and powerful when I do use it.

Mini magick20140916 29823 h6qxqr big
Tabasco
edgrant

I've been forcing myself to script things in PowerShell that I could do fairly easily and quickly with the GUI. I have a few scripts that will save maybe 10-15 seconds each time I run them, but the time does add up. Plus, it's way cooler to invoke a script and see something happen automagically instead of clicking. I find myself doing something and thinking, "Why haven't I automated this yet?" and I write a simple script for it. Usually it's less than 10 lines of code, but is still really powerful.

Mini magick20151027 25027 rgb421 big
Serrano
ToddNH

Am I a PuTTy scrappling?  A Command Prompt deck-hand?  A DOS sous chef?

No.  I am PowerShell Sorcerer.

Mini magick20151008 42431 138oafx big
Datil
Thomas0311

ToddTMS wrote:

Am I a PuTTy scrappling?  A Command Prompt deck-hand?  A DOS sous chef?

No.  I am PowerShell Sorcerer.

That's ok. I'm a Powershell Jedi Master.
Mini magick20140619 23171 1rj1xb3 big
Thai Pepper
bobmccoy

The most effective inroad for PS is learning by doing.  But it seems to be a recurring error on the part of new adherents to try and "solve world peace" in their first script.  They'll go Google some script and try and shoehorn it into their environment, and then get all perplexed when it doesn't work.  Don't do that.  It just leads to frustration all around. 

Start simple.  Learn the basics first.  These are life lessons.  I don't know why sysadmins think it doesn't apply somehow to PS.  Get a book like "Learn PowerShell in 30 days of Lunches" and work through it (side note:  it took me three months to work through the book and I've been doing PowerShell since the early beta days of Monad, combination of wanting to try different variants and work-related distractions).

And every burgeoning scripter needs to know that your sudden interest in PowerShell, or an urgent need for something scripted in your environment does NOT constitute an emergency for the community.  We're all volunteers here.  And the regulars here are here because we genuinely love PS and enjoy helping others get to the same place.  But that doesn't change the fact that we all also have "day jobs", different levels of exposure, and varying environments where we may not be able to validate your issue or problem.  So bear with us as well.

All that said, get out there and do it.  Happy scripting!

Mini magick20151026 1898 hles25 big
Pure Capsaicin
Martin9700

I really agree with the start small part.  Vast majority of people start PowerShell by doing a new user script, not realizing how much work Active Directory Users & Computers does for you. The biggest stumbling block is creating a home directory which is surprisingly difficult in PowerShell.  There are some new modules out there to make it easier but we've seen people have difficulty using them in the community.  

Anyway.  Start small.  Work yourself up to the big stuff.

Mini magick20150202 21933 11asz6i big
Datil
TOODAMAX

Is Powershell like DOS batch files on steroids? Can you take something that was a batch file and make it work in PS?

Can you use PS to run commands on other systems like Linux\AIX\iSeries?

I'm very familiar with DOS bat files and also PSEXEC and I am wondering if the knowledge transfers somewhat?

Mini magick20151008 42431 138oafx big
Datil
Thomas0311

TOODAMAX wrote:

Is Powershell like DOS batch files on steroids? Can you take something that was a batch file and make it work in PS?

Can you use PS to run commands on other systems like Linux\AIX\iSeries?

I'm very familiar with DOS bat files and also PSEXEC and I am wondering if the knowledge transfers somewhat?

As long as you have a user account with the correct permissions, there is very little that Powershell cannot do on a Windows system. With the new support for OpenSSH, Powershell can also be used to communicate and manipulate Linux/Mac environments assuming you know the syntax for said environments. The best part, IMHO, about Powershell is the structure of the system. You can build your own cmdlets or modules through advanced functions to extend your control outside of the native powershell cmdlets.
Mini magick20150402 10531 1yoc6zw big
Datil
Gorfmaster1

I would have to admit that I am a powershell rookie. I have been slowly trying to use it more an more, and I Don't know why I never started earlier.

Mini magick.21491.39708 big
Thai Pepper
BloodHoundGang

MKarmil wrote:

The MVA got me started and I swear by it for beginners. Great tool to have now that I learned the language. It doesn't take much, and after you spend some time using it, it just makes sense.

Agreed, the 3.0 Jumpstart is what peaked my interest. After seeing what Jeffery Snover and Jason Helmick were able to do with such basic commands I was amazed. Now I try to figure out how do to do whatever I can in Powershell. 
Mini magick20151030 7085 1u3msr2 big
Chipotle
The Spruce Bruce

I've been slowly integrating PowerShell into my toolkit, and although it's difficult at first to get your head around, I do feel the power within it.  That's what keeps me going with it.  Command Prompt and batch scripting are great!  I'm liking PS more though.  It seems more of a natural shell than the segmented Command Prompt ecosystem.

Mini magick20151026 1898 hles25 big
Pure Capsaicin
Martin9700

The Spruce Bruce wrote:

...It seems more of a natural shell than the segmented Command Prompt ecosystem.

Which is exactly what PowerShell was designed to do.  If you have a couple of minutes read the Monad Manifesto by Jeffrey Snover.  This was his document to sell PowerShell to Microsoft, and to outline what it was.  This was before it was called PowerShell!  It's really fascinating, and really gives some background into why PowerShell is the way it is.

http://www.jsnover.com/Docs/MonadManifesto.pdf 

Avatar user
Pimiento
sebaguele

I'd be interested in learning PowerShell.

Mini magick.26554.64436 big
Cayenne
ManyHats08

I don't know about Sorcery... Everytime I try to really use PS an old man jumps on the bridge and tells me I shall not pass...

But seriously, the command structure is easy enough to learn it is the sorting of data and then applying actions to it that can get people into trouble. And yes I try to shoehorn scripts but when I turn to PS it is because I need a big job done. But I am also comfortable with DOS/Putty/Bash but not really PS. lol

And BTW thanks for putting this together. It will be a great help.

Mini magick20180413 16297 atzovt big
Jalapeno
Jianderson

No matter what anybody tells you, this is the most important lesson you'll find in this thread. Use it wisely. 

Set-ADUser username -Replace @{thumbnailPhoto=([byte[]](Get-Content ".\RickAstley.jpg" -Encoding byte))}


Mini magick20180702 23522 1x19c2 big
Poblano
Ryan (Netwrix)

Great read, I can also recommend to take a look at our Powershell scripting tutorial for beginners - https://blog.netwrix.com/2018/02/21/windows-powershell-scripting-tutorial-for-beginners/

Mini magick20180713 4337 1ykj3oo big
Poblano
The White Lady

Would you mind giving a few examples? I'm learning powershell and that sounds like a fun way to make myself think within the software. I feel like I'm learning nouns and verbs, and I get the basics but when I try to think of something to apply it all to I just go blank.