Hello - I am looking to pull the DatastoreClusters and then list the datastores as well with their size (total size, Used space, Free Space, Provisioned, Uncommitted space) and the total number of VM's on that datastore. I would also like to include what datacenter and clusters they are on. Is this possible? I would like to maybe limit what is shown to datastores that are 13% free space or less.
Thanks,
Lorri
looks like it but when I run it nothing is coming up...
And you are sure you have datastores that would get through the Where-clause?
Perhaps try changing the numbers to other thresholds.
I'll do some more tests as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ah yes that was it. I adjusted the thresholds and got some results. If I also want to add the columns for FreeSpace%, ProvisionedSpace% and Uncommitted%
are my calculations correct?
@{N='Freespace%';E={[math]::Round($_.FreespaceGB/$_.CapacityGB*100,1)}},
@{N='ProvisionedSpace%';E={[math]::Round((($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB)/$_.CapacityGB*100,1)}},
@{N='UnCommittedGB%';E={[math]::Round(($_.ExtensionData.Summary.Uncommitted/1GB)/$_.CapacityGB*100,1)}},
Thanks so much
Yes, looks good.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This works perfectly thanks so much. One last question I have though is that I am using this alert for few things. One is to send an email, however I only want the email to be sent when there is actual output. How do I add that into logic into the script?
Do you want to send an email for each datastore that hits the watermarks, or one email for all the datastores, and then only when there are datastores?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I just need to have one email for anything that meets the criteria please!
You mean something like this?
Only when there is something in $report will there be an email
$report = Get-Datastore |
where {((($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB)/$_.CapacityGB) -ge 1.75 -and
($_.FreeSpaceGB/$_.CapacityGB) -le 0.05} |
Select @{N='Datacenter';E={$_.Datacenter.Name}},
@{N='DSC';E={Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name}},
Name,CapacityGB,
@{N='FreespaceGB';E={[math]::Round($_.FreespaceGB,2)}},
@{N='ProvisionedSpaceGB';E={
[math]::Round(($_.ExtensionData.Summary.Capacity - $_.Extensiondata.Summary.FreeSpace + $_.ExtensionData.Summary.Uncommitted)/1GB,2)}},
@{N='UnCommittedGB';E={[math]::Round($_.ExtensionData.Summary.Uncommitted/1GB,2)}},
@{N='VM';E={$_.ExtensionData.VM.Count}}
$report | Export-Csv report.csv -NoTypeInformation -UseCulture
if($report){
Send-MailMessage -To me@domain.com -from you@domain.com -Subject 'Report' -SmtpServer mail.domain.com -Attachments report.csv -
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
exactly. perfect.
thank you.
Hi LucD ,
I am new to VMware and PowerCLi topics, I would like to generate a .csv file in following format :
ClusterName | ClusterCapacity | ProvisionedSpace | ClusterOverProvision% | Host OS Type
Thanks in advance.
I suggest to open a new thread for your question.
And explain if the values you want to see are only for storage?
Do you mean the ESXi version with 'Host OS Type'?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD, I have created new question, you can check here (PowerCLi script to get ClusterName | ClusterCapacity | ProvisionedSpace | ClusterOverProvision% | Ho... )
Hi LucD,
For me also its working fine but i need VM names also along with this out put, is it possible ?
Hi LucD,
Its working for me as well but i need VM names along with VM count against datastore, can you help me with this pls ?