首頁 > 資料庫 > mysql教程 > PowerTip of the Day-Accessing Object Properties

PowerTip of the Day-Accessing Object Properties

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
發布: 2016-06-07 15:30:32
原創
923 人瀏覽過

原文地址: http://powershell.com/cs/blogs/tips/archive/2010/06/08/accessing-object-properties.aspx 原文: Accessing Object Properties Objects store information in various properties. There are two approaches if you would like to get to the

原文地址:http://powershell.com/cs/blogs/tips/archive/2010/06/08/accessing-object-properties.aspx

原文:

Accessing Object Properties

Objects store information in various properties. There are two approaches if you would like to get to the content of a given property. One is commonly used among developers, the other one among admins. Both will get you the same result. Have a look:

# access PowerShell
$process = Get-Process -id $pid
# output entire object
$process
# read CPU usage only (developer version)
$process.CPU
# read CPU usage only (pipeline version)
$process | Select-Object -expandProperty CPU

 

翻译:

访问对象属性

一个对象会把很多信息存储到大量的属性当中。如果要访问其内容通常来说有两种方法。一种是在程序员当中最常用的方法,另一种是在管理员当中常用的。两种方法的结果都是一样的:

# 获取PowerShell进程实例
$process = Get-Process -id $pid
# 显示整个对象的信息
$process
# 读取CPU使用率属性 (程序员版本)
$process.CPU
#读取CPU使用率属性 (管道版本)
$process | Select-Object -expandProperty CPU

 

笔记:

$pid是一个内部保留变量?代表当前powershell运行的实例。(有待验证)

打点访问属性的方法应该是最熟悉不过的了,管道方式然后select-object –expandProperty感觉怪怪的。

相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板