Objects in the PowerShell
As we said at the beginning of this tutorial, PowerShell is based on object-oriented and not text-based as the traditional shell. The main reason is because the win platform in the management of the main object-oriented, so in order to conform to the characteristics of the system and our operating habits, PowerShell also inherited this feature. So unlike the traditional shell, in PowerShell, we can interact with objects randomly,
First come to know, what is Object--object
I do not know whether you have engaged in development experience. In fact, the concept of object-oriented is proposed in order to solve practical problems with program language better.
Don't say much nonsense, cut to the chase directly. In PowerShell, "object" refers to the act of gathering information or performing an action. Include attributes (information that we can collect) and methods (we can execute).
There is a vivid example--"bulb". The object is obvious and it is a light bulb. The properties of a light bulb may include its color, power, and type (fluorescent, incandescent or halogen lamps). For it to operate, or to call it a method, is the behavior that we can perform, such as opening and closing. It's easy to understand!
Let's look at the properties of an object in PowerShell and its methods.
First, you may often use it "Get-member", which is used to check which attributes and methods an object has.
For example:
Get-service | Get-member
Use this command to view the properties and methods of the "Get-service" T. In this example, we use a pipe character to deliver the command. The results of the operation are as follows:
Of course, we can use the parameters of "Get-member" to view all the attribute class objects of "Get-service", or the method class object.
For example:
View all attribute class objects for "Get-service"
Get-Service | Get-Member -MemberType Property<enter>
View all method class objects for Get-service
Get-Service | Get-Member -MemberType Method<enter>
Why do we emphasize objects so much? The reason is that in PowerShell, everything is an object.