Get the App
SLTechnology News&Howtos  ›  Servers  › 

PowerShell Learning Notes-- object (1)

Shulou Source: shulou.com Published: 2022-06-02 03:24:48 09月16日 Update

For me as an IT Pro, learning PowerShell is really not easy. No matter what it becomes in the future, it is now really a scripting language, a language! As soon as I hear functions, variables, objects, people who have a headache, let's list some concepts here for the time being, which need to be further digested.

1. Objects in PowerShell

[example]: Get-Process

As shown in the figure above, the result of command execution is presented in the form of a table, with each row called "object", each column called "property", all rows added together as "set", and "collection" used to be called "table".

[object]: table rows that represent a single thing, such as a process, a service

[attribute]: table column, my understanding: like entity attributes in a relational database, they are combined to describe an entity, such as a process name

[collection]: a collection of all related objects in memory after the command is executed

[method]: that is, behavior, that is, what the object can do, such as killing a process.

2. Why PowerShell uses objects

This part seems specious and understandable. Compared to Shell in Unix or Linux, the former is purely text-based, and PowerShell uses objects to eliminate all text manipulation overhead, allowing users to focus on completing tasks. PowerShell only needs to know the column name, does not care about the order of the columns in the table, and does not need to rewrite the command after the column is moved.

This part needs to be compared.

3. Exploring object

[command]: Get-Member

[alias]: Gm

[role]: understand the content of the object

[usage]: use after any command that can produce some output.

[case]: Get-Process | Gm, Get-Service | Gm

I'm completely dizzy. Take your time.

Tags: Objects commands attributes examples entities take your time text language process learning headaches specious seemingly unintelligible dizzy one line above that is things represent Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Linux Redmi macOS MySQL