Saturday, December 13, 2014

Powershell help - The three most important commands in the Windows PowerShell

Just starting out with the Windows PowerShell and I think the most important command are:

  • Get-help - first line support, what do I do?
  • Get-command - found the command, How do I use it?
  • Get-member - What does this do? List it's members.


It accepts wildcards and is not case-sesitive.
get-help *service* 
will list all topics that have object in the topic.

You can find more info about the topic by asking for help on the name of the specific.
get-help start-service
This help text is very useful but there's even more.

The full help can be found by using the verbose parameter, full
get-help start-service -full


get-command -noun service 
This will list all the commands with the word service in the name.

You can also look for a verb, e.g.
get-command -verb get


To use this we need to use the pipeline command which is:
Basically, without explaining pipelining, the output from the first command is filtered into the second.

So. I have found that the command I am interested in is get-service.
I want to find the members of that service. So I pipe the command into the get-member command.
get-service | get-member
 Running the above we find the Properties and Methods for the command get-service

And one other thing:


If you're unsure what a command will do, then add the -whatif parameter and let PowerShell tell you what will happen.

stop-process -name * -whatif 

No comments:

Post a Comment