Hi all,
Long time lurker,
I haven't been using PS for long and mainly just spit out one liners for things like "whats connected to X" etc
I am trying to output a file that I can put into excel and create some graphs used vs provisioned is the idea.
I would like to get this down so I can manipulate it for other entities.
I can wrap this around a foreach loop which I can figure out usually.
With get-stat I notice that it gets one value then the other so the MetricID is changing, so I cant just select the property.
I have a script already where I can show the last value and then put them all on the same graph but It would be cool to have a graph per datastore to see the trends.
We have vcops but I find the graphing a slow process as we have dozens of datastores globally.
this is my simple script I need to then cut and paste the values into additional columns but who wants to do it manually :smileysilly:
I can do something like this
$todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0)
$Startmonth = -1
$metrics = "disk.capacity.latest", "disk.provisioned.latest", "disk.used.latest"
$datastore = "vm_production01"
$arrds = Get-datastore | where-object {$_.Name -like $datastore}
$a = Get-Stat -Entity $arrds -Stat $metrics[0] -Start $todayMidnight.AddMonths($Startmonth) -Finish $todayMidnight | where {$_.instance -eq ""} | sort timestamp | select timestamp, value
$b = Get-Stat -Entity $arrds -Stat $metrics[1] -Start $todayMidnight.AddMonths($Startmonth) -Finish $todayMidnight | where {$_.instance -eq ""} | sort timestamp | select value
$c =Get-Stat -Entity $arrds -Stat $metrics[2] -Start $todayMidnight.AddMonths($Startmonth) -Finish $todayMidnight | where {$_.instance -eq ""} | sort timestamp | select value
$fin = $a + $b + $c
$fin = $a + $b + $c
$fin | ConvertTo-Csv | Out-File C:\support\scripts\development\datastoreusage.csv
See the attached file for the end goal.
I'm not sure if I am needing to create a custom object to accomplish it, If someone could help me out it would be great.
and any helpful articles where I can learn how to do it, I'm almost finished powershell in a month of lunches but I dont think this is covered :smileygrin:
thanks all