0%

0/1 Lessons

Course Introduction

• 5min

0 / 2 lessons complete

Getting Started with Windows PowerShell

• 56min

0 / 8 lessons complete

Getting Help and Finding Commands

• 39min

0 / 6 lessons complete

PowerShell Command Syntax

• 33min

0 / 5 lessons complete

PowerShell Objects and Properties

• 35min

0 / 6 lessons complete

The PowerShell Pipeline

• 24min

0 / 2 lessons complete

PowerShell Providers

• 30min

0 / 5 lessons complete

PowerShell Arrays and Variables

• 28min

0 / 4 lessons complete

PowerShell Loops

• 19min

0 / 3 lessons complete

PowerShell Conditional Statements

• 11min

0 / 1 lessons complete

On Premises Lab Setup

• 36min

0 / 8 lessons complete

Basic Domain Administration with Windows PowerShell

• 2hr 27min

0 / 10 lessons complete

Send Emails with PowerShell

• 22min

0 / 2 lessons complete

PowerShell Desired State Configuration (DSC) Basics

• 1hr 48min

0 / 6 lessons complete

PowerShell Modules

• 58min

0 / 7 lessons complete

Powershell Challenges

• 1hr 55min

0 / 23 lessons complete

Course Conclusion

• 1min

0 / 1 lessons complete

Command Syntax Part 3

Instructions

Q&A (0)

Notes (0)

Resources (0)

Saving Progress...

Resources

There are no resources for this lesson.

Notes can be saved and accessed anywhere in the course. They also double as bookmarks so you can quickly review important lesson material.

Create note

{ } Curly braces. In some of the commands you’ll see curly braces. I’ll show you what I mean.

Back to the parameter set 1. Checkout the parameter -Entrytype

Notice that it is surrounded by square brackets that start at -EntryType and end at warning} ]. That shows that the parameter is optional

But notice the curly braces surrounding {Error and ending at warning} 

Also notice the vertical lines between information | FailureAudit | SuccessAudit and Warning

What this means is, that if you want to use the parameter -Entrytype you have these  choices. 

Let’s try this

Type Get-EventLog application -EntryType warning, error -Newest 20

As you can see this command ran correctly

This command displays any warnings and errors coming from our applications that we are currently running.

Required Parameters 

There’s One thing that I need to show you. 

Let go back to the syntax for get-service. Take a look at the first parameter set, notice that the parameter -displayname doesn’t have the square brackets around it

This means that if you want to use the first parameter set, you would be required to use the parameter -DisplayName

That’s how you know what is required and what is optional.

Type get-service -displayname and pick an application press return, and as you can see that did command run. This command displays the service that is associated with the application.

So, in most instances this rule would hold true.

If there are no square brackets around the parameter and the argument, the parameter and the argument are required

If there are square brackets around the parameter and the argument the parameter is optional and not required.

Let’s go back to the get-evenlog syntax and review: 

Get in the habit of analyzing the syntax of a cmdlet

  1.  indicates a parameter
  1. < > angle brackets indicate an argument
  1. [ ] If there are two square brackets inside two angle brackets this means that the parameter can take multiple arguments, separated by a comma. In this case it would be two numbers.
  1. [Param Arg] Square brackets around the parameter and the argument.

Means the parameter is optional .

[Param] Square brackets around the parameter

Because -logname is surrounded by square brackets and the argument <string> is not, that makes -logname optional and the argument required

  1. Positional Because -logname is surrounded by square brackets 

and it’s position is 0, this makes this parameter positional.

So, PowerShell expects -logname and it’s value type to be first in the order of cmdlets.

  1. Named
  1. { } Curly braces - a parameter followed by several choices separated by vertical lines and surrounded by curly braces. 

Using this parameter, you can choose various items to expand the functionality of the cmdlet.

So, with what you have learned in the last two lectures you should be able to figure out command syntax. You’re on your way to understanding a lot more about PowerShell.

Server Academy Members Only

Sorry, this lesson is only available to Server Academy Full Access members. Become a Full-Access Member now and you’ll get instant access to all of our courses.

0 0 votes
Lesson Rating
Subscribe
Notify of
profile avatar