lorried82
Enthusiast
Enthusiast

looks like it but when I run it nothing is coming up...

Reply
0 Kudos
LucD
Leadership
Leadership

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

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

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

Reply
0 Kudos
LucD
Leadership
Leadership

Yes, looks good.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

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?

Reply
0 Kudos
LucD
Leadership
Leadership

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

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

I just need to have one email for anything that meets the criteria please!

Reply
0 Kudos
LucD
Leadership
Leadership

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

Reply
0 Kudos
lorried82
Enthusiast
Enthusiast

exactly. perfect.

thank you.

Reply
0 Kudos
NageshJ
Contributor
Contributor

Hi ,

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.

Reply
0 Kudos
LucD
Leadership
Leadership

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

Reply
0 Kudos
NageshJ
Contributor
Contributor

Reply
0 Kudos
davejohn7
Contributor
Contributor

Hi Is there anyway I can send these csv file output to a mail ID ? I'm totally from storage background and i don't know how it works. From storage end, we don't have the SNMP feature of fetching high utilized LUN, so everytime we need to login to almost 15 storage arrays and to fetch the storage details. So I would like to optimize the time here. Is there any way we can get these reports in our mail ?
Reply
0 Kudos
rachappachalmi
Enthusiast
Enthusiast

Hi LucD,

For me also its working fine but i need VM names also along with this out put, is it possible ?

Reply
0 Kudos
rachappachalmi
Enthusiast
Enthusiast

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 ?

Reply
0 Kudos