PowerShell SUNISH SURENDRAN KANNEMBATH

Slides:



Advertisements
Similar presentations
Lists, Loops, Validation, and More
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 15: Exception Handling.
Chapter 16: Exception Handling C++ Programming: From Problem Analysis to Program Design, Fifth Edition.
The Web Warrior Guide to Web Design Technologies
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Introducing Algorithms, Pseudocode and.
Chapter 6. 2 Objectives You should be able to describe: Function and Parameter Declarations Returning a Single Value Pass by Reference Variable Scope.
Guide To UNIX Using Linux Third Edition
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
Chapter 2 Basic SQL SELECT Statements
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 2 - Welcome Application: Introduction to C++
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
PMS /134/182 HEX 0886B6 PMS /39/80 HEX 5E2750 PMS /168/180 HEX 00A8B4 PMS /190/40 HEX 66CC33 By Adrian Gardener Date 9 July 2012.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 4 – Wage Calculator Application: Introducing.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Java Programming, Second Edition Chapter Five Input and Selection.
Input, Output, and Processing
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Using Client-Side Scripts to Enhance Web Applications 1.
Linux Operations and Administration
Chapter 14: Exception Handling. Objectives In this chapter, you will: – Learn what an exception is – Learn how to handle exceptions within a program –
CPS120: Introduction to Computer Science Decision Making in Programs.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Exam 1 Review Instructor – Gokcen Cilingir Cpt S 111, Sections 6-7 (Sept 19, 2011) Washington State University.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
JavaScript, Fourth Edition
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
CSC 1010 Programming for All Lecture 3 Useful Python Elements for Designing Programs Some material based on material from Marty Stepp, Instructor, University.
Chapter 15: Exception Handling C++ Programming: Program Design Including Data Structures, Fifth Edition.
STAGES Language Application Overview. The Language Application is available on a separate URL (typically /stagesLanguage) and tied to only one database.
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Chapter 4: Variables, Constants, and Arithmetic Operators Introduction to Programming with C++ Fourth Edition.
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Dept. of Computer & Information Sciences
ASP.NET Programming with C# and SQL Server First Edition
Information and Computer Sciences University of Hawaii, Manoa
Core Java Statements in Java.
Retrieving Data Using the SQL SELECT Statement
A variable is a name for a value stored in memory.
Topics Designing a Program Input, Processing, and Output
User-Written Functions
Completing the Problem-Solving Process
Introduction to Scripting
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
Scripts & Functions Scripts and functions are contained in .m-files
Week#2 Day#1 Java Script Course
Using Procedures and Exception Handling
Chapter 14: Exception Handling
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
Python Primer 2: Functions and Control Flow
Topics Introduction to File Input and Output
Chapter 3 The DATA DIVISION.
Introduction to C++ Programming
Exception Handling Chapter 9 Edited by JJ.
Part B – Structured Exception Handling
Classes and Objects.
Cmdlets “Command-lets”
Programming in C# CHAPTER - 7
Topics Introduction to Functions Defining and Calling a Void Function
7 Arrays.
Topics Introduction to Functions Defining and Calling a Function
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Debugging and Handling Exceptions
Topics Introduction to File Input and Output
Tutorial 11 Using and Writing Visual Basic for Applications Code
Presentation transcript:

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

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 www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

Difference b/w Full and Detailed Help www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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> www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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>] www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

Show-command www.ITinfratutorials.com |PowerShell

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 www.ITinfratutorials.com |PowerShell

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. www.ITinfratutorials.com |PowerShell

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. www.ITinfratutorials.com |PowerShell