您的位置:首页 > 运维架构 > Shell

我能用Windows PowerShell做什么:把数据显示成一个列表

2007-09-14 21:34 253 查看
注:本篇文章,未在联系作者以及得到许可的情况下, 禁止以任何形式进行转载。

By:Anders Mail:katrina520@163.com

把数据显示成一个列表

许多cmdlets (Get-Service,如这个命令),显示信息的表格形式。也许有时候,当你想把数据信息显示成一个列表的时候(特别是如果这个表格有太多的栏目,以很好的适合屏幕)。也许正如你所期望的,这个format-List cmdlet在这里作为一个列表的形式来帮你显示信息。

首先,这里用Get-Service cmdlet默认输出,像这个样子:


Status Name DisplayName


------ ---- -----------


Running AdobeActiveFile... Adobe Active File Monitor V4


Stopped Alerter Alerter


Running ALG Application Layer Gateway Service

当你通过用Format-List获得输出时就像这个样子:


Name : Spooler


DisplayName : Print Spooler


Status : Running


DependentServices : {}


ServicesDependedOn : {RPCSS}


CanPauseAndContinue : False


CanShutdown : True


CanStop : True


ServiceType : Win32OwnProcess, InteractiveProcess

大家可以看到,任何时候你使用Get-Service只要三个属性值就好在Windows PowerShell中显示一个表格。用Get-Service时一个方法可以得到所有有效的属性以及他们的值并且用Format-List输出。

这是一个很好的问题:我们如何用Format-List输出格式名单?这里:


Get-Service | Format-List

它是那么的简单。

英文原文:http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/format-list.mspx
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐