Share via


PowerShell Objects, Methods and Properties

PowerShell Objects, Methods and Properties

Object

An Object is a representation of something. It can be collection of items and actions to use them. In short an object is a combination of Methods and Properties - Where properties represents some information about the object and Methods are used to manage the data. Example: A ball is round in shape, red in color made using rubbers, available in different sizes. Ball Bounces. So here color, shape and manufacturing material represents properties and Bounces is a method.

help about_Objects -Detailed

help about_Methods -Detailed

Demo

Get-Process | GM -MemberType Method

Get-Process | GM -MemberType Property

Get-Command -ParameterType System.Diagnostics.Process

The above code will fetch all the properties and methods of Process. Where Process can be stopped and started as required. Let's try to stop and start the BITS service using PowerShell

Get-Service | GM -MemberType Method

Screen Shot

Invoke Start and Stop Method

(Get-Service -Name BITS).Stop()

(Get-Service -Name BITS).Start()

Enjoy PowerShell :)