Get the App
SLTechnology News&Howtos  ›  Servers  › 

PowerShell object-- PowerShell for three minutes (5)

Shulou Source: shulou.com Published: 2022-06-02 09:14:28 10月03日 Update

On the question of what is an object, I have really thought about it for a long time. It can be an abstraction of a concrete physical entity, an artificial concept, or a person and something with a clear boundary and meaning.

Why does PowerShell use objects in the first place?

You always need some way to represent data. Windows itself is an object-oriented operating system to make things simple.

Although you can interact with Windows PowerShell by typing commands in the text box, Windows PowerShell is still based on objects, not text. The output of the command is an object. You can send the output object to another command as its input.

For example, we usually run the command to get the result.

Object-as you can see, the "table row" represents a single thing, such as a single process or a single service.

Attributes-- so-called "table columns"-- they represent part of the information about the object, such as service name and service status.

Methods-- so-called "behaviors"-- methods are associated with an object and cause the object to perform certain tasks, such as stopping or starting a service.

Collection-this is a collection of all objects

So how do you get an object in the collection?

We know that a service contains not only three attributes: status, name and display name, but also startup type, dependent service, and so on. To view all information about an object, you can view it by formatting it into a list or exporting it.

Well, after introducing the date, we don't have to have a headache about not finding all the information.

Tags: Objects services commands representatives information singles names that is attributes text methods methods for example status output headaches operating systems three not just things Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux vpn Docker Redmi