CmdLet

Cmdlet are built in commands which are written in .net languages, which can be called from PowerShell command window or you can call it from your scripts too. You can create your own Cmdlets too.

You can pass objects or return object to or from Cmdlets. Windows PowerShell has huge collection of Cmdlets which makes programmers life easy and makes easy to communicate with Windows Operting system too.

Let's understand this with an example. Open PowerShell command window or open Windows PowerShell ISE, write "Get-ComputerInfo" and press enter or press F5 in Windows PowerShell ISE, it will return text stream which will let you know all about your computer e.g.

Example
Get-ComputerInfo

It will show output something like below

Example
WindowsBuildLabEx                                       : 18362.1.amd64fre.19h1_release.190318-1202
WindowsCurrentVersion                                   : 6.3
WindowsEditionId                                        : Enterprise
WindowsInstallationType                                 : Client
WindowsInstallDateFromRegistry                          : 06-07-2019 07:31:01
WindowsProductId                                        : xxxxx-xxxxx-xxxxx-xxxxx
WindowsProductName                                      : Windows 10 Enterprise
WindowsRegisteredOrganization                           : 
WindowsRegisteredOwner                                  : admin
WindowsSystemRoot                                       : C:\WINDOWS
WindowsVersion                                          : 1909

................

So here you will see readable format output, where as Cmdlets returns .NET object but Windows PowerShell parses it, does formating it self and makes it presentable, that is not usually a part of any Cmdlets.

As I said there is a huge collection of Cmdlets and you can see whole list in Windows PowerShell ISE in Commands Pane. To see syntax of any Cmdlets you can use Get-Help which will return syntax and other information of that Cmdlets e.g.

Example
Get-Help Get-ComputerInfo

If you execute above command, you will get output as below.

Example
NAME
    Get-ComputerInfo
    
SYNTAX
    Get-ComputerInfo [[-Property] ]  []
    

ALIASES
    gin
    

REMARKS
    Get-Help cannot find the Help files for this cmdlet on this computer. It is displaying only partial help.
        -- To download and install Help files for the module that includes this cmdlet, use Update-Help.
        -- To view the Help topic for this cmdlet online, type: "Get-Help Get-ComputerInfo -Online" or 
           go to https://go.microsoft.com/fwlink/?LinkId=799466.

Here you will not get anything in "Remarks" if you haven't downloaded help in you local system, so it will give you a link to go online for more help.

gin is the alias of "Get-ComputerInfo", so if you write gin and press Enter key it will show information about your computer.

 

← Previous