From the course: PowerShell 5 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Working with methods

Working with methods - PowerShell Tutorial

From the course: PowerShell 5 Essential Training

Start my 1-month free trial

Working with methods

- So far in this chapter we've been working with properties. We've been creating our own properties by doing custom columns and calculated properties. We've been selecting and sorting and filtering. Now it's time to do a little bit with methods. Now the methods are listed the same way. Anytime you wanna know anything there is to know about an object you pipe it to get-member. GM is the alias and anything that says method is something this object can do. I want you to notice something about this get-service. The objects here and the object type is a ServiceController. I want you to notice that it has methods start and stop. I wanna show you a way to do this. As an example I want you to pretend for a second. You already know that get-service name bits, you already know that it's stopped right now. I could start it by doing start-service. Pretend for a second though that this commandlet doesn't exist and this will happen to you in real life. You're gonna be able to grab hold of an object…

Contents