磁盘计数器表格格式
Posted
技术标签:
【中文标题】磁盘计数器表格格式【英文标题】:Disks' counters tabular format 【发布时间】:2013-10-19 18:08:27 【问题描述】:Get-Counter '\PhysicalDisk(*)\% Idle Time', '\LogicalDisk(*)\Free Megabytes','\PhysicalDisk(*)\Avg. Disk sec/Read','\PhysicalDisk(*)\Avg. Disk Queue Length'|Select-Object -expandProperty countersamples|Select-Object -Property instancename, cookedvalue | ft -AutoSize
如何像这样格式化“Get-counter”命令的输出。
【问题讨论】:
【参考方案1】:$counters="\PhysicalDisk(*)\% Idle Time","\PhysicalDisk(*)\Avg. Disk sec/Read","\PhysicalDisk(*)\Avg. Disk Queue Length","\PhysicalDisk(*)\Avg. Disk sec/Write"
Get-Counter $counters |Select-Object -expandProperty CounterSamples | group InstanceName | foreach
$ht=New-Object System.Collections.Specialized.OrderedDictionary
$ht.Add("Drive",$_.Name.ToUpper().Replace("_",""))
foreach($item in $_.Group)
$perfCName=$item.Path.Replace(("(" + $item.InstanceName + ")"),"").Split("\")[3,4] -join "\"
$ht.Add($perfCName,$item.CookedValue)
New-Object PSObject -Property $ht
| ft
【讨论】:
以上是关于磁盘计数器表格格式的主要内容,如果未能解决你的问题,请参考以下文章
phpexcel导入excel表格,导入后自动为科学计数法5.1115E+14