以下是我參考網路上寫出來的語法
但是有個問題我無法排除
一台虛擬機可能有scsi0:0 或ide0:0
我無法單獨選擇我要的類型合併顯示
不知道語法哪裡需要修改
麻煩 指導我一下 感激不盡
I learn from the Internet to write following script
But there is a problem I can not solve
A virtual machine may use scsi0: 0 or ide0: 0
Can not single type combinations to display
I do not know where the script need to be modified
Please tell me how to modify the script
Thank you very much
============================================
$entity = Get-Vm | where {$_.NAME -eq "eBOOK"}
$APP = @()
$runday = ((get-date).day -1)
$day = (get-date).day
$runmonth = (get-date).month
$runyear = (get-date).year
$metrics = "cpu.usage.average","cpu.usagemhz.average","cpu.ready.summation","cpu.capacity.entitlement.average","cpu.corecount.contention.average","mem.usage.average","mem.swapinRate.average","mem.swapoutRate.average","mem.vmmemctl.average","mem.consumed.average","mem.overhead.average","mem.capacity.entitlement.average","mem.capacity.usage.average","disk.usage.average","net.usage.average","virtualDisk.throughput.usage.average"
$savepath = "c:\" + $entity + "-" + "$runyear" + "-" + "$runmonth" + "-" +"$runday" + ".csv"
$start = "$runmonth"+"/"+"$runday"+"/"+"$runyear"
$finish = "$runmonth"+"/"+"$day"+"/"+"$runyear"
$stats = Get-Stat -Entity $entity -Stat $metrics -Start $start -Finish $finish
$stats | where {"ide0:0","scsi0:0" -contains $_.Instance}| Group-Object -Property Instance | where {$_.Timestamp -ne "",$_.value -ne ""} | %{
$_.Group | Group-Object -Property {$_.Timestamp} | %{
$row = "" | Select "time","cpu_usage_average","cpu_usagemhz_average","cpu_ready_summation","cpu_capacity_entitlement_average","cpu_corecount_contention_average","mem_usage_average","mem_swapinRate_average","mem_swapoutRate_average","mem_vmmemctl_average","mem_consumed_average","mem_overhead_average","mem_capacity_entitlement_average","mem_capacity_usage_average","disk_usage_average","net_usage_average","virtualDisk_throughput_usage_average"
$row."time" = $_.Group[0].Timestamp
$row."cpu_usage_average" = $_.Group[0].value
$row."cpu_usagemhz_average" = $_.Group[1].value
$row."cpu_ready_summation" = $_.Group[2].value
$row."cpu_capacity_entitlement_average" = $_.Group[3].value
$row."cpu_corecount_contention_average" = $_.Group[4].value
$row."mem_usage_average" = $_.Group[5].value
$row."mem_swapinRate_average" = $_.Group[6].value
$row."mem_swapoutRate_average" = $_.Group[7].value
$row."mem_vmmemctl_average" = $_.Group[8].value
$row."mem_consumed_average" = $_.Group[9].value
$row."mem_overhead_average" = $_.Group[10].value
$row."mem_capacity_entitlement_average" = $_.Group[11].value
$row."mem_capacity_usage_average" = $_.Group[12].value
$row."disk_usage_average" = $_.Group[13].value
$row."net_usage_average" = $_.Group[14].value
$row."virtualDisk_throughput_usage_average" = $_.Group[15].value
$APP += $row
}
}
$APP |sort time