PowerTipoftheDay-AccessingObjectProperties
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了PowerTipoftheDay-AccessingObjectProperties,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1470字,纯文字阅读大概需要3分钟。
内容图文
原文地址: 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感觉怪怪的。
内容总结
以上是互联网集市为您收集整理的PowerTipoftheDay-AccessingObjectProperties全部内容,希望文章能够帮你解决PowerTipoftheDay-AccessingObjectProperties所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。