The object, format and parameters of "exploring PowerShell" and "four" PowerShell

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.