Although you might not realize it at first, when you work in Windows PowerShell, you are working with .NET Framework objects. As you gain experience, the power of object processing becomes more evident, and you'll find yourself using the objects and even thinking in objects.

Technically, a .NET Framework object is an instance of a .NET Framework class that consists of data and the operations associated with that data. But you can think of an object as a data entity that has properties, which are like characteristics, and methods, which are actions that you can perform on the object.

For example, when you get a service in Windows PowerShell, you are really getting an object that represents the service. When you view information about a service, you are viewing the properties of its service object. And, when you start a service, that is, when you change the Status property of the service to "started," you are using a method of the service object.

All objects of the same type have the same properties and methods, but each instance of an object can have different values for the properties. For example, every service object has a Name and Status property. However, each service can have a different name and a different status.

When you're ready, it's easy to learn about the objects. To find out what type of object a cmdlet is getting, use a pipeline operator (|) to send the results of a "get" command to the Get-Member command. For example, the following command sends the objects retrieved by a Get-Service command to Get-Member.

get-service | get-member 

Get-Member displays information about the service object, including the typename of the object and a list of its properties and methods.

   TypeName: System.ServiceProcess.ServiceController

Name                      MemberType    Definition
----                      ----------    ----------
Name                      AliasProperty Name = ServiceName
add_Disposed              Method        System.Void add_Disposed(EventHandler value)
Close                     Method        System.Void Close()
Continue                  Method        System.Void Continue()
...

For information about the object class, copy and paste the typename, such as System.ServiceProcess.ServiceController, in MSDN. When you find the class, you can read the MSDN subtopics to learn about the properties and methods of objects based on that class, like the ones in Windows PowerShell.

To find the values of all of the properties of a particular object, use a pipeline operator (|) to send the results of a "get" command to a Format-List or Format-Table command. Use the Property parameter of the format cmdlets with a value of all (*). For example, to find all of the properties of the Schedule service on the system, type:

get-service schedule | format-list -property *

The following shows an example of the result.

Name                : Schedule
CanPauseAndContinue : True
CanShutdown         : True
CanStop             : True
DisplayName         : Task Scheduler
DependentServices   : {}
MachineName         : .
ServiceName         : Schedule
ServicesDependedOn  : {RpcSs}
ServiceHandle       : SafeServiceHandle
Status              : Running
ServiceType         : Win32ShareProcess
Site                :
Container           :

You don't need to understand anything about objects when you are first learning Windows PowerShell, but keep the concept in the back of your mind. You'll soon be able to use the objects to their best advantage.




Table Of Contents