【问题标题】: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”命令的输出。

【问题讨论】:

    标签: powershell formatting performancecounter powershell-3.0


    【解决方案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
    

    【讨论】:

      猜你喜欢
      • 2012-02-25
      • 1970-01-01
      • 1970-01-01
      • 2011-07-13
      • 2014-05-02
      • 1970-01-01
      • 2012-06-10
      • 2013-02-06
      • 1970-01-01
      相关资源
      最近更新 更多