Powershell : Command your CMDLET’s


A cmdlet is a lightweight command that is used in the Windows PowerShell environment.

SYNTAX :

Verb-Noun -Parameter Value -SwitchParameter

a

  • Command name

    Commands always begin with a command name, such as New-Alias. Type the command name or its alias, such a “gcm” for Get-Command.

  • Parameters

    The parameters of a command are options that determine what the command does. Some parameters take a “value,” which is user input to the command.
    For example, the Get-Help command has a Name parameter that lets you specify the name of the topic for which help is displayed. The topic name is the value of the Name parameter.

    In a Windows PowerShell command, parameter names always begin with a hyphen. The hyphen tells Windows PowerShell that the item in the command is a parameter name.

    For example, to use the Name parameter of New-Alias, you type the following:
    -Name

  • Parameter Values

    A parameter value is the input that the parameter takes. Because Windows PowerShell is based on the Microsoft .NET Framework, parameter values are represented in the syntax diagram by their .NET type.

    For example, the Name parameter of Get-Help takes a String value, which is a text string, such as a single word or multiple words enclosed in quotation marks.

PowerShell cmdlets have a Verb-Noun syntax, which can be seen above. The important thing to note is that the noun is always singular even though the cmdlet might return more than one result.

Here, syntax is capitalized for readability, but Windows PowerShell is case-insensitive.

To see a list of legal verbs in PowerShell you can use the Get-Verb cmdlet.

get

Knowing and understanding legal verbs and keeping in mind the singular noun rule will assist you in guessing cmdlet names.
For example, suppose you want to get a list of services and their status – that’s right, its as easy as

Get-Service

How do you think we would get a list of running processes – Atta Boy! 😀 that’s right

Get-Process

pro

Powershell Cmdlet’s facilitates a platform to work upon multiple technologies. For example, install Active Directory modules in your powerhsell and check users and groups on the fly.

Get-ADUser

Include the exchange module and check mailboxes and other attributes.

Get-Mailbox

ALIASES :

Powershell comes with this cool feature, which will make your life damn easy. Aliases provide you multiple ways to run the same commands.

For example, You want to get list of items present in current directory, you could run the command

Get-ChildItem

gci

Or, you could simply type and run the command gci which is an alias for Get-ChildItem.

gci

Some of the aliases are just like Linux commands like , ls which is again an alias for Get-ChildItem

ls

Happy Learning !

Advertisements

2 thoughts on “Powershell : Command your CMDLET’s

  1. I am in powershell command prompt window .
    I type get-command cmdlet and i press enter
    there its not displaying “get-aduser” under the name column . what am I doing wrong ?

    Like

  2. Please type in below cmdlet, and before that please make sure you have the Active Directory module in you powershell.

    PS C:\> Get-Command *aduser*

    CommandType Name ModuleName
    ———– —- ———-
    Cmdlet Get-ADUser ActiveDirectory
    Cmdlet Get-ADUserResultantPasswordPolicy ActiveDirectory
    Cmdlet New-ADUser ActiveDirectory
    Cmdlet Remove-ADUser ActiveDirectory
    Cmdlet Set-ADUser ActiveDirectory

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s