Exploring .NET objects
An object is nothing but a combination of methods and properties in PowerShell. Using Windows PowerShell, we can store a reference to an object to a variable and use it in the current shell as required.
We discussed in Chapter 1, Getting Started with Windows PowerShell that PowerShell takes advantage of the underlying .NET framework. So, the objects are a representation of the parts and actions to use it. An object is a combination of the properties and methods (Objects = Properties + Methods).
For example, a Windows service object has properties and methods. The properties are Get
and Set
, and the methods are invoked to perform a meaningful operation.
Consider the following image:
Creating .NET objects
We have discussed objects in a few of the preceding examples as well. In this section, we will explore the .NET objects in PowerShell. In order to create a .NET object, we will use the same New-Object
cmdlet, but instead of the COM object, we will use different types of...