2 most important powershell commands you must know before learning azure powershell
Cmdlets
Specialized commands in the PowerShell environment are Cmdlets that implement specific functions. These follow a Verb-Noun naming pattern, such as Get-help.
Get-Help
Get-Help cmdlet provides basic information about articles, commands and other powershell concepts.
This is the first command that you should learn before you go further into subject. It works like search bar to the powershell scripting language.
Understanding importance of the cmdlet
Usually, when you open powershell console all you need to do is hit a command to get your desired results, right.
Let`s say…
You forgot the command but you know what information is required for you. Enough!! with this you can complete the task.
For example,
One day, Ram wants to get the all processes running in his system. So, he opened powershell console and to his surprise he forgot the command that he needs to use.
He didn’t worry at all as he know the use of get-help command. He hit command as follows
C:\>get-help process
Then it listed all the commands that are related to word process just as below. On seeing the results, he recollected the command and that’s it he done with this work.
| get-help process command |
This is why get-help is first command that you should know at the earliest.
Knowing the right command for the purpose is not enough. Knowing the usage of command is also most important factor.
To do this, Ram hit the following command that he chosen in the above result.
C:\>Get-help get-process
It gives structure of get-process command that need to executed. In that we can mandatory and optional parameters of the command.
Result of Get-help Get-process command |
At last, he got to know about command he started using and getting the results as below.
Get-Process command result |
And the last but not least is get-Member.
Get-Member:
It gets the members, the properties and methods that are associated with command.
Using this cmdlet, you can come to know advance features of any command. Knowing this stuff, you can play with any command.
Lets see how Ram use this cmdlet…
C:\>Get-process | get-member
It gives all the processes running in the system as below. He finds all properties and functions associate with it.
properties of Get-process command |
Now, he wants to find process ID of some process (Example: explorer process noticed in the result of get-process command)
He used following command using property called ID that is listed in the above result.
$(get-process explorer).id
It brings following result.
process details with get-process command |
getting process id with using property of powershell object |
Comments
Post a Comment