is there a way to get a list of datastore's capacity, used space, allocated space for the past week with an interval of 120mins with the date?
I searched through the internet but couldnt find a solution...
Oops, my bad.
I forgot to ask for the aggregate instance, hence the multiple values for those 2 metrics.
Try like this
$dsName = 'DSNAME'
$start = (Get-Date).AddDays(-7)
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name $DSNAME
$report = Get-Stat -Entity $ds -Stat $stat -Start $start -Instance "" |
Group-Object -Property Timestamp | %{
New-Object PSObject -Property @{
DSName = $dsName
Date = $_.Name
Used = $_.Group | where{$_.MetricId -eq 'disk.used.latest'} | select -ExpandProperty Value
Cap = $_.Group | where{$_.MetricId -eq 'disk.capacity.latest'} | select -ExpandProperty Value
Provisioned = $_.Group | where{$_.MetricId -eq 'disk.provisioned.latest'} | select -ExpandProperty Value
}
}
$report | Select DSName,Date,Used,Cap,Provisioned
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this.
Note that you will need one of the more recent PowerCLI version.
Datastore metric support was added not that long ago.
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name MyDS
$start = (Get-Date).AddDays(-7)
Get-Stat -Entity $ds -Stat $stat -Start $start
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for your help
The script comes out with 334 different types of UiD
I just want one freespce,used space,provisionedspace(optional) for each time for a particular datastore.
This is what I have so far
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name DSNAME
$start = (Get-Date).AddDays(-7)$report = Get-Stat -Entity $ds -Stat $stat -Start $start
$report | Export-Csv -Path PATH -NoTypeInformation -UseCulture
I also made one like this that comes out with 1 for each time but it only shows the capacity.
Used and Provisioned comes out like this → "System Object []"
$start = (Get-Date).AddDays(-7)
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name DSNAME$report = Get-Stat -Entity $ds -Stat $stat -Start $start |
Group-Object -Property Timestamp | %{
New-Object PSObject -Property @{
DSName = $dsName
Date = $_.Name
Used = $_.Group | where{$_.MetricID -eq 'disk.used.latest'} | select -ExpandProperty Value
Cap = $_.Group | where{$_.MetricID -eq 'disk.capacity.latest'} | select -ExpandProperty Value
Provisioned = $_.Group | where{$_.MetricID -eq 'disk.provisioned.latest'} | select -ExpandProperty Value
}
}$report | Select DSName,Date,Used,Cap,Provisioned |
Export-Csv -Path PATH-NoTypeInformation -UseCulture
Not sure what you mean with 334 different types of UiD?
The script will for for a specific datastore, return all metrics for the last week.
Do you want the average over a week for each property then?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sorry for making it confusing.
I want a historical data of a specific datastore's free space and capacity.
So, I want a historical data of the script below
Get-Datastore -Name DSNAME | Select Name,FreeSpaceGB,CapacityGB | Export-Csv PATH -NoTypeInformation -UseCulture
But that should be exactly what the script I gave earlier is providing.
What is the problem with the output?
Perhaps you can show part of the output, and indicate what is incorrect in there?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
When I use the first script you gave me, it gives me 54443 lines.
When I use the script below, it gives me the image below the script.
I was thinking I would get a single number for each used and provisioned space.
$dsName = 'DSNAME'
$start = (Get-Date).AddDays(-7)
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name $DSNAME
$report = Get-Stat -Entity $ds -Stat $stat -Start $start |
Group-Object -Property Timestamp | %{
New-Object PSObject -Property @{
DSName = $dsName
Date = $_.Name
Used = $_.Group | where{$_.MetricId -eq 'disk.used.latest'} | select -ExpandProperty Value
Cap = $_.Group | where{$_.MetricId -eq 'disk.capacity.latest'} | select -ExpandProperty Value
Provisioned = $_.Group | where{$_.MetricId -eq 'disk.provisioned.latest'} | select -ExpandProperty Value
}
}$report | Select DSName,Date,Used,Cap,Provisioned
Thankyou for your help
Oops, my bad.
I forgot to ask for the aggregate instance, hence the multiple values for those 2 metrics.
Try like this
$dsName = 'DSNAME'
$start = (Get-Date).AddDays(-7)
$stat = 'disk.used.latest','disk.capacity.latest','disk.provisioned.latest'
$ds = Get-Datastore -Name $DSNAME
$report = Get-Stat -Entity $ds -Stat $stat -Start $start -Instance "" |
Group-Object -Property Timestamp | %{
New-Object PSObject -Property @{
DSName = $dsName
Date = $_.Name
Used = $_.Group | where{$_.MetricId -eq 'disk.used.latest'} | select -ExpandProperty Value
Cap = $_.Group | where{$_.MetricId -eq 'disk.capacity.latest'} | select -ExpandProperty Value
Provisioned = $_.Group | where{$_.MetricId -eq 'disk.provisioned.latest'} | select -ExpandProperty Value
}
}
$report | Select DSName,Date,Used,Cap,Provisioned
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thank you LucD, it worked how i wanted to!!!