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

Section Overview
Full Access Account Required

Video | 5 min

The Trusted Hosts List Challenge
Full Access Account Required

Text | 5 min

The Trusted Hosts List Answer
Full Access Account Required

Video | 5 min

Starting a Remote Session Challenge
Full Access Account Required

Text | 5 min

Starting a Remote Session Answer
Full Access Account Required

Video | 5 min

Rename a Computer Challenge
Full Access Account Required

Text | 5 min

Rename a Computer Answer
Full Access Account Required

Video | 5 min

Change a Password on a Remote Computer Challenge
Full Access Account Required

Text | 5 min

Change a Password on a Remote Computer Answer
Full Access Account Required

Video | 5 min

How to Copy Files To-From a Remote Machine Challenge
Full Access Account Required

Text | 5 min

How to Copy Files To-From a Remote Machine using VSC Answer
Full Access Account Required

Video | 5 min

How to Export Logs to a CSV File Challenge
Full Access Account Required

Text | 5 min

How to Export Logs to a CSV File Answer
Full Access Account Required

Video | 5 min

How to Create Multiple Folders on the Host Machine using Powershell
Full Access Account Required

Text | 5 min

How to Create Multiple Folders on the Host Machine using Powershell Answer
Full Access Account Required

Video | 5 min

Who Rebooted the Server ID1074 Challenge
Full Access Account Required

Text | 5 min

Who Rebooted the Server
Full Access Account Required

Video | 5 min

How can you get Info on all your Hard Drives Challenge
Full Access Account Required

Text | 5 min

How can you get Info on all your Hard Drives Answer
Full Access Account Required

Video | 5 min

How can I get a list of CPU's and Installed Printers, Last Boot-up Time Challenge
Full Access Account Required

Text | 5 min

How can I get a List of CPU's and Installed Printers, Last Boot-up Time Answer
Full Access Account Required

Video | 5 min

How can I Automate Tasks with Task Scheduler Challenge
Full Access Account Required

Text | 5 min

How can I Automate Tasks with the Task Scheduler Answer
Full Access Account Required

Video | 5 min

Course Conclusion

• 1min

0 / 1 lessons complete

Objects, Properties and Methods Part 2

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

Let’s take a look at some examples using Methods:

We’re going to be using get-process and the process named notepad

  • First let’s open notepad, open your search bar and press notepad, minimize to the taskbar
  • Type get-process, press return, press return again. Scroll up, and we see that notepad is running. Press return and cls.
  • Type get-process -name notepad press return, now press return again

In our boat and car illustration we showed you that objects contain properties and methods, but when we take a look at get-process there are no methods or properties listed.

So, the question is, how can I display the property or methods for get-process?

  • By using a special command called get-member. We’ll use the alias gm for get-member.
  • Type get-process -name notepad | gm. (Use pipe operator) That’s the symbol right above the enter key. Press your shift key and your pipe operator.

If you recall, a pipeline takes the output of one command and pushes it through to the input of the second command. 

So, get-process has a process called notepad, and you’re piping the output of notepad into the input of get-member. Press return

  • There is some very important information, when using get-member. 

It’s TypeName. Typename tells us what kind of object that is being sent across the pipeline. In this case the TypeName is System.Diagnostics.Process but we’ll just use the last part which is process. Just keep that in mind, you’ll need it later when we get to the pipeline lecture.

  • Notice the method called kill. Kill is definitely an action.

Go ahead and type this out then we’ll explain it

  • Type (Get-Process Notepad).kill() 
  • To use a method of an object, Place the cmdlet name and the argument in parenthesis, then type a dot (.), then the method name, and a set of parentheses "()"

The parentheses are required for every method call, even when there are no arguments.

The point is that we don’t need a separate cmdlet to close the process notepad we have the method kill. Press return

And we see that notepad has been closed.

Let’s try another example of using Methods

  • Let’s say we want to copy files from one location to another. In this case we’ll use the get-childitem command.
  • Let open windows explorer, for demonstration purposes I’ve created a folder named content

Double click on content and we have a text file named computers. click that file and displayed is the contents of the text file. 

  • Now we want to copy this file from the C:\content folder to the c:\test folder using a method called copyto.

Type get-childitem | GM – (Pipe operator) press return

Notice the get-childitem TypeName: is FileInfo 

We’ll use the copyto method to copy a file from one location to another

  • We don’t need a cmdlet, not when we have the copyto method, press return

Let’s go ahead and type the command then I’ll explain it.

Type (Get-childitem C:\content\computers.txt). copyto("C:\test\computers.txt") 

  • Put the cmdlet name and the argument in parenthesis then type a dot (.), the method name, in this case is copyto. and a set of parentheses "()"

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
2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

profile avatar
Ambrose Garza(@ambroseg)
Member
1 year ago

Every time I ran the get-childitem | gm command it would tell me the type was directory info and not file info. I was running it from c:\users\administrator directory when I switched to c:\windows\system32 it showed the type as both directory info and file info.

Last edited 1 year ago by Ambrose Garza
profile avatar
Ricardo P(@ricardop)
Admin
Reply to  Ambrose Garza
1 year ago

Hi profile avatar Ambrose Garza
That’s correct, same behavior from my end.
The difference is in what the folder contains.
Ricardo