PowerShell is more than just a command line shell. It is a configuration management framework that the command line shell is part of, but also a scripting language.
It is more powerful than the Windows command prompt but also more intimidating. While it has been there for more than a decade, most Windows users are probably not very familiar with PowerShell.
This guide provides you with information on learning PowerShell, by using PowerShell. This may sound confusing at first, but it is not really. What I try to do here is to give you commands at hand that help you understand PowerShell commands.
Please note that this is not a complete PowerShell tutorial that teaches you all there is to know about it. It is designed to give you tools at hand that you can use whenever you stumble upon PowerShell commands, or want to do something using PowerShell but don't know how to.
It all begins by starting a new PowerShell command line shell.
Note: Some commands, the updating of help files for instance, may require elevation.
The command Get-Command lists all PowerShell Cmdlets when you run it. This may not look super useful right away.
If you use Get-Command | Format-List * instead, you get a formatted listing instead that lists, among other things, the help file URI of each command.
If you want all those help file links, use Get-Command | Get-Help | Out-File c:\ps\help.txt. This gets all help topics of all cmdlets, and saves them to the help.txt file on c:\ps.
You may also filter the listing, by using a command such as Get-Command *process. This lists all commands with process in their name (meaning all that manipulate processes).
First thing you may want to do is update the help file. Not all help topics are available by default, and running the command ensures that they are up to date and available locally.
Run Update-Help, and wait for the process to finish.
Want to force updates and all? run the command update-help -Module * -Force instead.
As far as help commands are concerned, the main one is get-help "cmdlet", e.g. get-help get-command to display information about get-command. Running get-help displays the following for the selected command.
You may also display the help of a cmdlet by appending -? to its command, e.g. Update-Help -?.
The command get-help -detailed displays detailed information about the command. Please note that the command does not work on all cmdlets.
The command get-help "command" -full lists all information that is available. This includes examples, notes, inputs and outputs, and more on the screen.
You may display the online version of help for a command by using the -online parameter, e.g. Get-Help Format-List -Online.
The command Get-Help * on the other hand lists all help topics that are available.
To get help about parameters, use the command Get-Help "command" -Parameter "Name", e.g. Get-Help Format-List -Parameter GroupBy.
Last but not least, you may use Get-Help "word" to list topics that include the word you have specified, e.g. Get-Help process.
Sometimes, all you need is an example to find out more about a cmdlet. You can use the command get-help "cmdlet" -examples, e.g, get-help write-verbose -examples, to list examples that reveal how the cmdlet is used.
To display help content in a new window instead of the one you run the command in, use get-help "command" -ShowWindow, e.g. get-help write-verbose -ShowWindow.
Aliases help you type commands faster. The best way to know about aliases is to run get-alias. The command lists them all in the interface.
The following online resources are excellent when it comes to learning more about PowerShell:
Please click on the following link to open the newsletter signup page: Ghacks Newsletter Sign up
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.
thanks, been looking for an article like this
As someone who validates powershell scripts made by various members of the team on a daily basis, I’d say the last tip(learn and use alias) is actually a terrible one. Powershell is nice to read, like python, because it is very verbose and self descriptive, but when you start to use aliases, it becomes a total pain to decipher. Tip 5 should be : Aliases exist, don’t use them in the name of readability/maintainability.
Agree. Alias makes the scripts hard to read even for someone used to PowerShell.
actually, the tip is great. If I come from Linux, I don’t want to learn powershell for some basic command line usage. Just type Linux commands and it works. If you’re writing scripts, it is a different matter.
Thanks. Very handy. Bookmarked it and might use it someday, if I muster the courage.
I have found useful;
Get-Module -ListAvailable
That lists modules, so pick one you like the look of and;
Get-Command -Module Defender
To see all commands for the module.