Thursday, 20 August 2015

Using Get-Help ?

Get-Help is one of the most important and frequently used cmdlet in PowerShell in My opinion and this has been First Said by the Inventor himself, Mr. Jeffrey Snover .

Why because , a person who doesn't know about a command and its use, Get-Help is the best way to figure it out.

So lets start with Get-Help .

Open Windows Powershell and Type Get-Help.

Here You will get help about Get-Help itself.

How to Get-help for a cmdlet ?

Type 
PS C:\> Get-Help -Name Get-ChildItem and hit enter.

Here it Tells about the Get-Childitem cmdlet that it Gets the files and Folders in a file system drive.

and you can see the syntax here.

SYNTAX
    Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] [-Exclude <String[]>] [-Force] [-Include <String[]>] [-Name] [-Recurse] [-UseTransaction
    [<SwitchParameter>]] [<CommonParameters>]

    Get-ChildItem [[-Filter] <String>] [-Exclude <String[]>] [-Force] [-Include <String[]>] [-Name] [-Recurse] -LiteralPath <String[]> [-UseTransaction
    [<SwitchParameter>]] [<CommonParameters>]

    Get-ChildItem [-Attributes <FileAttributes]>] [-Directory] [-File] [-Force] [-Hidden] [-ReadOnly] [-System] [-UseTransaction] [<CommonParameters>]

and the detailed information is provided by the Description Which includes the link for the help.

DESCRIPTION
    The Get-ChildItem cmdlet gets the items in one or more specified locations. If the item is a container, it gets the items inside the container, known as child
    items. You can use the Recurse parameter to get items in all child containers.

    A location can be a file system location, such as a directory, or a location exposed by a different Windows PowerShell provider, such as a registry hive or a
    certificate store.
    In a file system drive, the Get-ChildItem cmdlet gets the directories, subdirectories, and files. In a file system directory, it gets subdirectories and files.

    By default, Get-ChildItem gets non-hidden items, but you can use the Directory, File, Hidden, ReadOnly, and System parameters to get only items with these
    attributes. To create a complex attribute search, use the Attributes parameter. If you use these parameters, Get-ChildItem gets only the items that meet all
    search conditions, as though the parameters were connected by an AND operator.

    Note: This custom cmdlet help file explains how the Get-ChildItem cmdlet works in a file system drive. For information about the Get-ChildItem cmdlet in all
    drives, type "Get-Help Get-ChildItem -Path $null" or see Get-ChildItem at http://go.microsoft.com/fwlink/?LinkID=113308.

And more, You will get related cmdlets too !!! 

If you need examples, Just type 
PS C:\> Get-Help Get-ChildItem -Examples


Here you will get examples for the Get-Childitem cmdlet, if not you can update the help files uisng
Update-Help cmdlet.

So, The best way to learn PowerShell is , Open Windows PowerShell and type Get-Help,
Then Get-Help Get-Help -Examples .

You Just want to explore it That's all...





No comments:

Post a Comment