1

I would like to give me a link or a document where I Can understand coding syntax of a help manual of a specific programming language.

In the command below, for example, what is the meaning of [] or []<String[]> or []<>{| | |} ?

I hope that you understand my question

Get-ChildItem [[-Path] <String[]>] [[-Filter] <String>] [-Attributes {read-only | Hidden | System | Directory |
    Archive | Device | Normal | Temporary | SparseFile | ReparsePoint | Compressed | Offline | NotContentIndexed |
    Encrypted | IntegrityStream | NoScrubData}] [-Depth <UInt32>] [-Directory] [-Exclude <String[]>] [-File] [-Force]
    [-Hidden] [-Include <String[]>] [-Name] [-Read Only] [-Recurse] [-System] [-UseTransaction] [<CommonParameters>]

1 Answer 1

3

Check out about_Command_Syntax on the official Powershell documentation.

SYNTAX DIAGRAMS

Each paragraph in a command syntax diagram represents a valid form of the command.

To construct a command, follow the syntax diagram from left to right. Select from among the optional parameters and provide values for the placeholders.

PowerShell uses the following notation for syntax diagrams.

<command-name> -<Required Parameter Name> <Required Parameter Value>
[-<Optional Parameter Name> <Optional Parameter Value>]
[-<Optional Switch Parameters>]
[-<Optional Parameter Name>] <Required Parameter Value>

Regarding <>

The .NET type of a parameter value is enclosed in angle brackets < > to indicate that it is placeholder for a value and not a literal that you type in a command.

{}

Braces {} indicate an "enumeration," which is a set of valid values for a parameter.

[]

A right and left bracket [] appended to a .NET type indicates that the parameter can accept one or multiple values of that type. Enter the values in a comma-separated list.

I won't copy paste everything but head up there to get more insights on the syntax.

Sign up to request clarification or add additional context in comments.

1 Comment

Revisiting this helpful answer, let me suggest two improvements: It's worth mentioning that [-<Optional Parameter Name>] parameters are called positional parameters. May be worth adding the [[-<Optional Parameter Name>] <Optional Parameter Value>] variant (currently missing from the docs), i.e. an optional positional parameter (an example is Start-Process' -ArgumentList parameter).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.