) is [-Name] values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] New-Alias -Name MyAlias Get-Process [-Name] Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope ] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] [-Value] produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell"> ) is [-Name] values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] New-Alias -Name MyAlias Get-Process [-Name] Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope ] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] [-Value] produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell">

Presentation is loading. Please wait.

Presentation is loading. Please wait.

PowerShell SUNISH SURENDRAN KANNEMBATH

Similar presentations


Presentation on theme: "PowerShell SUNISH SURENDRAN KANNEMBATH"— Presentation transcript:

1 PowerShell www.ITinfratutorials.com SUNISH SURENDRAN KANNEMBATH
The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to

2 Basics of PowerShell TOPIC: HELP and ERROR HANDLING
The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

3 PowerShell Help Update-Help - updates help from Microsoft or from local share Should be part of Local Administrator group PowerShell must be run with elevated privileges Use –Force, if want to update help more than once in 24hrs. Get-help, Help or Man Help -Category Cmdlet -Name *service* Get-help Update-Help, Get-Help Get-Service -Detailed, -Full, and –Examples Get-help Get-Service -ShowWindow The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

4 Difference b/w Full and Detailed Help
|PowerShell

5 Cmdlet Syntax Syntax Definition
<Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Value>[] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

6 Cmdlet Syntax - Command Name
Syntax Definition <Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] Required for required options or values they will not be enclosed in any bracket. Options or values enclosed in [ ] are optional Values are represent with the type they take between < > Those values that can be lists are represented as <type[ ]> Those that have a predefined list of options it can take are represented as < option1 | option2 | option3> |PowerShell

7 Cmdlet Syntax - Required Parameter
Syntax Definition <Command-Name> -Required Parameter Name <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

8 Cmdlet Syntax - Optional Parameter and Value
Syntax Definition <Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

9 Cmdlet Syntax - Switch Parameter
Syntax Definition <Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

10 Cmdlet Syntax - Optional Parameter, Required Value
Syntax Definition <Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

11 Cmdlet Syntax - Multiple Parameter Values
Syntax Definition <Command-Name> -<Required Parameter Name> <Required Parameter Value> [-<Optional Parameter Name> <Optional Parameter Value>] [-<Optional Switch Parameters>] [-<Optional Parameter Name>] <Required Parameter Value> <Multiple Parameter Values>[] Syntax Sample PS C:\> Get-Command –Name Add-Computer –Syntax Add-Computer [-DomainName] <string> -Credential <pscredential> [-ComputerName <string[]>] [-LocalCredential <pscredential>] [-UnjoinDomainCredential <pscredential>] [-OUPath <string>] [-Server <string>] [-Unsecure] [-Options <JoinOptions>] [-Restart] [-PassThru] [-NewName <string>] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] The syntax diagrams use the following symbols: -- A hyphen (-) indicates a parameter name. In a command, type the hyphen shown in the syntax diagram. immediately before the parameter name with no intervening spaces, as For example, to use the Name parameter of New-Alias, type: -Name it with the item that it describes. angle brackets or the placeholder text in a command. Instead, you replace -- Angle brackets (<>) indicate placeholder text. You do not type the Angle brackets are used to identify the .NET type of the value that group of words that are enclosed in quotation marks. cmdlet, you replace the <string> with a string, which is a single word or a a parameter takes. For example, to use the Name parameter of the New-Alias optional, or the name of a required parameter can be optional. -- Brackets ([ ]) indicate optional items. A parameter and its value can be enclosed in brackets because they are both optional. For example, the Description parameter of New-Alias and its value are [-Description <string>] required, but the parameter name, "Name," is optional. The brackets also indicate that the Name parameter value (<string>) is [-Name] <string> values in a comma-separated list. the parameter can accept one or multiple values of that type. Enter the -- A right and left bracket ([]) appended to a .NET type indicates that one string, but the Name parameter of Get-Process can take one or For example, the Name parameter of the New-Alias cmdlet takes only many strings. New-Alias [-Name] <string> New-Alias -Name MyAlias Get-Process [-Name] <string[]> Get-Process -Name Explorer, Winlogon, Services for a parameter. -- Braces ({}) indicate an "enumeration," which is a set of valid values one value from the set of values that are listed inside the braces. indicate an "exclusive or" choice, meaning that you can choose only The values in the braces are separated by vertical bars ( | ). These bars value enumeration for the Option parameter: For example, the syntax for the New-Alias cmdlet includes the following -Option {None | ReadOnly | Constant | Private | AllScope} The braces and vertical bars indicate that you can choose any one of the listed values for the Option parameter, such as ReadOnly or AllScope. -Option ReadOnly cmdlet syntax description, the Scope parameter is optional. This is Brackets ([]) surround optional items. For example, in the New-Alias Optional Items and type: indicated in the syntax by the brackets around the parameter name [-Scope <string>] Both the following examples are correct uses of the New-Alias cmdlet: New-Alias -Name utd -Value Update-TypeData -Scope global New-Alias -Name utd -Value Update-TypeData parameter name but not the parameter type, as in this example from the required. This is indicated in the syntax by the brackets around the A parameter name can be optional even if the value for that parameter is New-Alias cmdlet: [-Name] <string> [-Value] <string> produce the same result. The following commands correctly use the New-Alias cmdlet. The commands New-Alias utd Update-TypeData New-Alias utd -Value Update-TypeData New-Alias -Name utd Update-TypeData PowerShell tries to use the position of the arguments to assign the If the parameter name is not included in the statement as typed, Windows values to parameters. The following example is not complete: New-Alias utd This cmdlet requires values for both the Name and Value parameters. element is optional. .NET Framework types. In this context, brackets do not indicate an In syntax examples, brackets are also used in naming and casting to |PowerShell

12 Cmdlet Syntax PS C:\> Get-Command –Name Stop-Process –Syntax
Stop-Process [-Id] <int[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] Stop-Process -Name <string[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] Stop-Process [-InputObject] <Process[]> [-PassThru] [-Force] [-WhatIf] [-Confirm] [<CommonParameters>] |PowerShell

13 Syntax Legend <verb-noun> Command name
-<parameter> Required parameter name <value> Required parameter value [-<> <>] Optional parameter and Optional value [-<>] <> Optional parameter and Required value <value[ ]> Multiple parameter values |PowerShell

14 Show-command |PowerShell

15 ERROR Handling Terminating error -A serious error during execution that halts the command (or script execution) completely. Non-Terminating error -A non-serious error that allows execution to continue despite the failure. Error occurs during execution, it is logged to a global variable called $error $error[0].InvocationInfo and $error[0].Exception |PowerShell

16 ERROR Action Preference
Available choices for error action preference: SilentlyContinue – error messages are suppressed and execution continues. Stop – forces execution to stop, behaving like a terminating error. Continue – the default option. Errors will display and execution will continue. Inquire – prompt the user for input to see if we should proceed. Ignore – (new in v3) – the error is ignored and not logged to the error stream. Has very restricted usage scenarios. |PowerShell

17 Try /Catch The Try, Catch, and Finally statements allow us to control script flow when we encounter errors. PowerShell will write the exit code directly to $LastExitCode. Exit code - 0 – success - 1 or greater - failure. |PowerShell


Download ppt "PowerShell SUNISH SURENDRAN KANNEMBATH"

Similar presentations


Ads by Google