PowerShell - useful commands to know

PowerShell - useful commands to know

PowerShell can be daunting for those who are completely new to the scripting language. This is a brief post about some useful commands to know when starting out


You want to do something, but don't know the command name, or even if there is a command that does that. Use Get-Command with wildcards around what you want. For example: "what is that command that does something with users?"

PS> Get-Command *user*


Ah yes, Get-ADUser, that's what I wanted


You've found a command, but how does it work? What do you do with it? HELP! Anyone, how do I GET HELP for this command?

PS> Get-Help Get-ADUser

You can also get extended help by appending -full to the command


And use the -Online switch and see your browser of choice open the Microsoft PowerShell doc for the command


You've used a command, it's returned some output, but is that the full output? Is there anything else? What's behind the curtain? Use Get-Member to see the behind-the-curtain properties and methods. To use this command, 'pipe' your variable/command to the 'Get-Member' cmdlet


Tab complete is your friend

PowerShell supports a tab complete mechanism. Start typing the first few letters of a cmdlet name, or a parameter name and then press tab. The first matching name will be populated. Press tab again and the next matching name will come up. I find this very useful in times when I can remember a bit of the cmdlet name, but can't remember the exact spelling of it (read: I'm a bad speller and quite often can't spell the cmdlet properly!!)


This is intended to be brief. There's loads more tips and tricks I use, plenty more I've seen but never used, and more after that. This is for PowerShell beginners I talk to at work, but I hope you find it useful too