Trying to added numbers of chargeback for thin discs

All,

I found a verion of the below script here but I need to change so that we only charge for use when a thin disk is used as not all VM is still thin.

Y at - it an easy way to add a disk usage if her thin instead of assigned capacity...  I would need to keep the appearance of tiered of the script storage.

$report = @)

#Get all s Vm, need info and understand storage

#get - vm - name NHN | % {

Get - vm | % {

$vm = $_

$T1 = ($_ | get-HDD |) Where-Object {$_.} Filename-match 'Mirror'} | measure - object - property CapacityKB-sum). Sum

$T2 = ($_ | get-HDD |) Where-Object {$_.} Filename-match "Fiber" - and $_. Filename-match "CF"} | measure - object - property CapacityKB-sum). Sum

$T3 = ($_ | get-HDD |) Where-Object {$_.} Filename-match 'SATA'} | measure - object - property CapacityKB-sum). Sum

$_ | Get-Datastore. Where-Object {$_.} Type - eq "VMFS"} | % {

$row = "" | Select - the name of the property, MemoryMb NumCPU, "T1 (GB) ',' T2 (GB) ',' T3 (GB) ', 'Cost Center', 'Cost of storage', 'Extra CPU', 'Extra Mem', 'Total'"

$row. Name = $vm. Name

$row. MemoryMb = $vm. MemoryMb

$row. NumCpu = $vm. NumCpu

$row. {T1 (GB)} = "" f ($T1 / 1 Mb)

$row. {T2 (GB)} = "" f ($T2 / 1 Mb)

$row. {T3 (GB)} = "" f ($T3 / 1 Mb)

  1. need custom field cost center

$row. {Cost center} is $vm. CustomFields.Item ('Cost Center')

  1. Start doing the calculations

$row. {Store cost} = (($row.)) {} T1 (GB)} * 5.2) + ($row. {} T2 (GB)} * 2.6) + ($row. {} T3 (GB)} * 1))

if($Row.) NumCpu - gt 1) {[int] $row.} {{} Additional CPU} = 450}

Else {[int] $row.} {{} Additional CPU} = 0}

if($Row.) MemoryMb - gt 2084) {[int] $row.} {} Extra Mem} = (($row.)) MemoryMb - 2084) *. (02)}

Else {[int] $row.} {} Extra Mem} = 0}

$row. = ($row.{ Storage cost} + $row. {Extra CPU} + $row. {Additional Mem} + 550)

$report += $row

}

}

  1. print to excel

$report | Sort - Name property. Sort - unique name. Export-Csv "C:\chargeback.csv" - noTypeInformation

#$report | Sort - Name property. Sort - unique name

Sorry for the delay, kind of lost that on my list

Try the attached script

____________

Blog: LucD notes

Twitter: lucd22

Tags: VMware

Similar Questions

Maybe you are looking for