• 2. Powershell Cmdlet

    Posted on January 29, 2013 by in Desktop Engineering, Powershell, Scripting

    Command to know the version of Powershell

    Type

     Get-Host <enter> 

    In the below example you will notice that the powershell version 3.0 is being displayed.

    There are four categories of PowerShell commands:

    1. Cmdlet (Command-Let)
    2. PowerShell Functions
    3. PowerShell Scripts
    4. Native Windows commands.

    PowerShell commands have been standardized using a “verb-noun” naming convention know as a cmdlet. This standard simplifies the learning curve and provides a better description of what the cmdlet does. To see a list of cmdlets available in PowerShell type the following cmdlet:

    Get-command <enter>
     
    <enter> denotes typing the Enter/Return key on your keyboard.
    Commands in PowerShell are NOT Case Sensitive

    The “Name” column lists the cmdlets in the “verb-noun” naming convention.

    To list all the commands that use a specific verb. The following command yields all cmdlets that use the verb “Set”

    get-command -Verb Set <enter>

    Try finding commands that use the verbs; Add, Clear, New, and Get.

    Similarly you can use commands that use specific nouns. Type the following command to see which cmdlets use the noun “computer”

    get-command -Noun computer <enter>

    Getting help
    In learning new technologies, it is important to find information quickly and easily. Get-Help cmdlet has been designed for that purpose; this will be the most utilized cmdlet until you become more proficient.

    Get-Help Examples:
    Information about Get-Help cmdlet. Includes description, syntax, and remarks.

    Get-Help

    Information about all available help topics.

    Get-Help *

    Information about a specific cmdlet.

    Get-Help Get-Service

    Two other forms of the Get-Help cmdlet exist, the noun “Help” and the “-?” parameter. Help, by itself provides the same info as Get-Help *. Use Help with a cmdlet as follows, Help Get-Service. With the help parameter, Get-Service -?.

    Using Cmdlets

    To know all the cmdlets associated with the noun Service

     Get-command -noun service <enter>

    To know what services are running on the computer Type cmdlet:

    get-service <enter>

    To know the status of a specific service  Type:

    Get-service -name Ampagent <enter>

    To Start a particualr service Type:

    Start-service -name Ampagent <enter>

    To Stop a specific service Type:

    stop-service -name Ampagent <enter>

    In this example we are using Ampagent service.

    This example should give you an idea on how to use cmdlets. start playing with different cmdlets to get more idea on them.

    Be Sociable, Share!

    Written by

    Senior Desktop/Infrastructure Engineer with over 10 years of proven experience in planning,designing & implementation of enterprise level Workstation builds for Finance, Pharmaceuticals, Telecommunication and other Domains. Desktop Engineer cannot rest as, Desktop world is very different it is fast paced, new technologies evolve and change at a rapid pace. For more info please visit: www.linkedin.com/in/srinivaskolla

    View all articles by

    Email : [email protected]

    Leave a Reply