The Three BIG help Giants of PowerShell

There are so many features and benefits to learning and using powershell that you only need the beginning point to get you started into this amazing world of learning and using powershell.

This post will cover all three of the basic commands that you will need to know to get started with powershell like a pro.


Let's get started.


Get-Help

  • Get-Help is a multipurpose command.

  • Get-Help helps you learn how to use commands once you find them.

  • Get-Help can also be used to help locate commands


In order to use get help with the Get-Service command we will type the following command

Get-help -Name get-service

It will return very basic help information, including the name of the command and the syntax also called "parameters sets" and the alias of the command.

If you got "Remark" message that says that "Get-Help cannot find the help files" it means that you need to update your Powershell help system.


You can do it by just typing this command

PS C:\Users\MeniTasa> Update-Help -UICulture en-US -Force -ErrorAction SilentlyContinue

-Uiculture = Only download files for this language

-Force = Forcing it to download everything

-ErrorAction SilentlyContinue = If some help topics are not updated or don't exist, this "SilentlyContinue" action will continue the operation without stopping.


There are a number of ways to carry out a command.

If you want to see some examples for a particular command, this command could be of use to you

PS C:\Users\MeniTasa> get-help get-service -Examples

It demonstrates how to use the command by giving you examples of how to do it

Here is a cool tip for you :) if one of the examples appeals to you, you can just highlight it and right click on it to copy it to your clipboard, and then you can paste that code into your console and run it.



Want more details?

Used this one if you want more details

get-help Get-Service -Detailed

The command will give you the basic help info for the command, with examples already provided but it will also add parameter descriptions.


Get the full help, not less.

To get the full Help you just need to type this command:

PS C:\Users\MeniTasa> get-help Get-Service -Full

This command will give you access to everything that the help system has to offer like additional information, input and output object types, attribute descriptions, and more...


Not in the CLI, please!

If you would like to view the Help section in your browser window, you may do so by using the following command:

PS C:\Users\MeniTasa> Get-help Get-Service -Online

It will show you all the help that is available in the Microsoft documentation


 

Learn the Syntax.


Let's start by learning how to read the commands and how to use them correctly, and that's where the fun part comes in. So let's get started


When I just type Get-Random without any parameters, it will just produce random numbers to the console. I used this command as a learning tool to learn the syntax.



Get-Random [[-Maximum] <System.Object>] [-Count <System.Int32>] [-Minimum <System.Object>] [-SetSeed <System.Nullable`1[System.Int32]>]
[<CommonParameters>]

First, let's examine the first section of the syntax

[[-Maximum] <System.Object>]

[] = what's inside [] it's optional


[-Maximum] (Specifies a maximum value for the random number) = You can see that the Maximum parameter is with [] what means that it's optional and you can just skip it and enter the value, for example

PS C:\Users\MeniTasa> Get-Random 100
13

[-Count <System.Int32>] = In this example we can see that the Count parameter is not with [] what means that if you use it you must provide a value <System.Int32> (System.Int32 means Integer).


PS C:\Users\MeniTasa> Get-Random 100 -Count
Get-Random: Missing an argument for parameter 'Count'. Specify a parameter of type 'System.Int32' and try again.
PS C:\Users\MeniTasa> Get-Random 100 -Count 4
97
65
17
48

If perhaps you see something like this <System.Object[]> it means you can enter multiply values to the parameters


We can see this parmeter [[-Name] <System.String[]>] in the get-command syntax.

We can provide him with multiple values, like get-timezone and get-acl

PS C:\Users\MeniTasa> Get-Command -name Get-TimeZone,Get-Acl

CommandType     Name                                            
Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-TimeZone                                       7.0.0.0    Microsoft.PowerShell.Management
Cmdlet          Get-Acl                                            7.0.0.0    Microsoft.PowerShell.Security

Another useful thing you should know is that, if you see {}, it means that you have to choose your value from predefined options set for example:


[-Option {None | ReadOnly | Constant | Private | AllScope}]
New-Alias [-Name] <string> [-Value] <string> [-Description <string>]
[-Force] [-Option {None | ReadOnly | Constant | Private | AllScope}]
[-PassThru] [-Scope <string>] [-Confirm] [-WhatIf] [<CommonParameters>]

 

Get-Command


The purpose of this command is as simple as it sounds, it helps you find commands in the world of power-shell


The Get-Command cmdlet gets all commands that are installed on the computer, including cmdlets, aliases, functions, filters, scripts, and applications.

Get-Command gets the commands from PowerShell modules and commands that were imported from other sessions.


Get information about a cmdlet.

PS C:\Windows\System32> Get-Command Get-AppLockerPolicy

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-AppLockerPolicy                                1.0        AppLocker

To get all the commands from specific module you can use this command:

PS C:\Windows\System32> Get-Command -Module ExchangeOnlineManagement
CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Connect-ExchangeOnline                             2.0.5      ExchangeOnlineManagement
Function        Connect-IPPSSession                                2.0.5      ExchangeOnlineManagement
Function        Disconnect-ExchangeOnline                          2.0.5      ExchangeOnlineManagement
Function        Get-WrappedCommand                                 2.0.5      ExchangeOnlineManagement
Function        IsCloudShellEnvironment                            2.0.5      ExchangeOnlineManagement

In order to find a command based on a specific verb and noun, you can use the following command: -Verb "Get" and the Noun starting the letter C

PS C:\Users\MeniTasa> Get-Command -Module Microsoft.PowerShell.Management -Verb Get -Noun C*

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Get-ChildItem                                      7.0.0.0    Microsoft.PowerShell.Management
Cmdlet          Get-Clipboard                                      7.0.0.0    Microsoft.PowerShell.Management
Cmdlet          Get-ComputerInfo                                   7.0.0.0    Microsoft.PowerShell.Management
Cmdlet          Get-Content                                        7.0.0.0    Microsoft.PowerShell.Management
 

Through reading this post, I hope you better understand how to start working with Powershell.

On Microsoft's website, you can find documentation for Get-command, as well as all the other commands we discuss in this post.


I encourage you to check out my website to read more articles like this on various topics related to information technology.


Thank you

Meni Tasa




7 views0 comments