VMware Cloud Community
Marcus316
Enthusiast
Enthusiast

PowerCLI script for vSphere capacity planning

Hello everyone!

After recent discussion on vSphere Capacity planning, I thought I would share one of the tools I use for this purpose. This is a side project I've been working on for few months.

I present to you, my very own "VMware Capacity & Performance Report PowerCLI script (v2.1 Community edition)"

http://1drv.ms/1J00vkq

(Click here then click on "Download")

This is a complex PowerCLI script I wrote, that generates an e-mail report that gives you insight into the current state of your VMware vSphere environment's capacity. It generates tables, pie charts and line charts with information about CPU, Memory & Storage capacity, VM Provisioning Potential, Cluster Resilience and more. Check the script's #INFORMATION block for more information about prerequisites, script input and output.

Have a look at the report it generates and let me know what you think of it!

Please share your thoughts and comments!

Marc Davoli

http://ca.linkedin.com/in/marcvincentdavoli/

Edited on May 25 : Changed OneDrive link to updated script v2.1 with bugfix (for cluster names with a space in it)

160 Replies
Sivaramsharmar
Enthusiast
Enthusiast

Hi Mummonth,

Replace $ClusterTemp.Name with below using Doublequotes and try it once.

"$ClusterTemp.Name"

0 Kudos
anilandhale
Contributor
Contributor

Hi Mummonth,

Even I faced same issue. used following code which resolved it

$FName = $ClusterTemp.Name  -replace " ","%20"      #defined new variable FName which replaces space in cluster name with %20 ( HTML way)

$HTMLBody += "<IMG SRC=Cluster_" + $FName + "_CPU_Usage.png>" # replaced $ClusterTemp.Name with $FName

$Attachments += "Cluster_" + $ClusterTemp.Name + "_CPU_Usage.png"

hope it would be helpful to you as well.

mummonth
Enthusiast
Enthusiast

Thank you, anilandhale, your solution worked fine for me!

0 Kudos
Marcus316
Enthusiast
Enthusiast

Hi Anilandhale,

Indeed, if you see problems with the script formatting, you can just go to the generated HTML page to look at the code and that should at least give you a hint as to which part of the script caused the error.

Thanks for helping out!

Marc

0 Kudos
Marcus316
Enthusiast
Enthusiast

Hello all,

I just posted version 2.1 of the script on the first page of this post : PowerCLI script for vSphere capacity planning

This version includes the bugfix for cluster names with spaces in it.

Thanks to anilandhale for posting a potential solution.!

Marcus

0 Kudos
vipal
Contributor
Contributor

Hello All,

When i run this script, i am not getting proper cpu utilization chart (attached). ON y axis it show only 50 and if u see memory utilization chart it show 100.  Can some one help me to figure out this.

0 Kudos
jitla1971
Enthusiast
Enthusiast

Hi All

Great script, as mentioned before.

Need some help, as im not very good with scripting and i wouldnt know what to change or where to make the changes, hence the request for help.

My manger has asked, if its possible to change the script so that it no longer sends an email daily.

Instead it produces a daily output file on a server, as we run the script daily.

File when saved, should include the date in the title, so its easy to know which date the file refers to.

If anyone can assist it would be appreciated.

0 Kudos
anilandhale
Contributor
Contributor

Hi jitla1971,

I hope following will be helpful.

1. If you want to store it locally on the server then you need to created directory for every day

    adding following at the end of  PREPROCESSING section will do it for you.

    $DIRName = Get-Date -UFormat "%Y-%m-%d-%H-%M"

    $FLocation = "<path>" + $DIRName  #replace path with actual location on the server ex: C:\CPReports\VC01\

    IF ((Test-Path -path $FLocation) -ne $True) {$TempFolder = New-Item $FLocation -type directory} else {$TempFolder = $FLocation}

    Set-Location $FLocation # create directory

2. export HTML contents to local file

     Adding following in the "SEND REPORT BY E-MAIL"  section will do it for you.

     $HTMLPage | Out-File ((Get-Location).Path + "\$DIRName.html")

3. To disable daily email comment out or remove the "Send-Mailmessage" line

0 Kudos
ashoks005
Contributor
Contributor

Hi Marcus,

Script is running successfully but im getting double entries for all hosts & datastores in report. Is anything need to be modified in the script.@

0 Kudos
LucD
Leadership
Leadership

Are you sure there aren't multiple connections open ?

Check the content of $global:defaultviservers.


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

0 Kudos
Ankojin
Contributor
Contributor

Hi Marc,

Great work ...Just checked it works for me nicely

I have few queries in script. could you please answer .

1.In datastores section last column showing commitment %. Here how the calculation is doing ,because for some datastores showing 100% above.

Datastore report.jpg

2.The other thing I'd like to know is if there is a way to exclude certain data stores from the script?

3.I'd like to remove all local host storage, so only my SAN shows in the report.

4.Datastore inventory showing in cluster session , So How can exclude the datastore inventory from each cluster session.

5.Report receiving in Email body , So where i can change as attachment in the script.

6. How slot is calculating for CPU and  memory and is there any possibilities  to set thresholds.

Thanks,

Ankoji

0 Kudos
Ankojin
Contributor
Contributor

Hi Lucd,

I have few queries in script. could you please help me out .

1.In datastores section last column showing commitment %. Here how the calculation is doing ,because for some datastores showing 100% above.

53132_53132.jpgDatastore report.jpg

2.The other thing I'd like to know is if there is a way to exclude certain data stores from the script?

3.I'd like to remove all local host storage, so only my SAN shows in the report.

4.Datastore inventory showing in cluster session , So How can exclude the datastore inventory from each cluster session.

5.Report receiving in Email body , So where i can change as attachment in the script.

6. How slot is calculating for CPU and  memory and is there any possibilities  to set thresholds.

0 Kudos
Ankojin
Contributor
Contributor

Hi Marcus,

I have few queries in script. could you please help me out.

1.In datastores section last column showing commitment %. Here how the calculation is doing ,because for some datastores showing 100% above.

53132_53132.jpgDatastore report.jpg

2.The other thing I'd like to know is if there is a way to exclude certain data stores from the script?

3.I'd like to remove all local host storage, so only my SAN shows in the report.

4.Datastore inventory showing in cluster session , So How can exclude the datastore inventory from each cluster session.

5.Report receiving in Email body , So where i can change as attachment in the script.

6. How slot is calculating for CPU and  memory and is there any possibilities  to set thresholds.

0 Kudos
Ankojin
Contributor
Contributor

Hi Anilandhale,

I have few queries in script. could you please answer if you know,

1.In datastores section last column showing commitment %. Here how the calculation is doing ,because for some datastores showing 100% above.

53132_53132.jpgDatastore report.jpg

2.The other thing I'd like to know is if there is a way to exclude certain data stores from the script?

3.I'd like to remove all local host storage, so only my SAN shows in the report.

4.Datastore inventory showing in cluster session , So How can exclude the datastore inventory from each cluster session.

5.Report receiving in Email body , So where i can change as attachment in the script.

6. How slot is calculating for CPU and  memory and is there any possibilities  to set thresholds.

Thanks,

Ankoji

0 Kudos
Ankojin
Contributor
Contributor

Hi

I have few queries in script. could you please answer if you know,

1.In datastores section last column showing commitment %. Here how the calculation is doing ,because for some datastores showing 100% above.

53132_53132.jpgDatastore report.jpg

2.The other thing I'd like to know is if there is a way to exclude certain data stores from the script?

3.I'd like to remove all local host storage, so only my SAN shows in the report.

4.Datastore inventory showing in cluster session , So How can exclude the datastore inventory from each cluster session.

5.Report receiving in Email body , So where i can change as attachment in the script.

6. How slot is calculating for CPU and  memory and is there any possibilities  to set thresholds.

Thanks,

Ankoji

0 Kudos
jitla1971
Enthusiast
Enthusiast

Hello

I am running the script against vCenter 6 Update 1, but i seem to be getting errors when it comes to colours and graphs.

Has anyone come across these errors and if so what can i do to fix these errors.

Chart Errors.PNG

Any help would be appreciated.

Thanks

Jitla

0 Kudos
punjain
Contributor
Contributor

This is because you opened it in notepad and it has now got "\" added in various locations, usually at the end of each row. Now based on the rows and character info you will need to remove  this and run the script.

0 Kudos
punjain
Contributor
Contributor

Hi Marcus,

I am getting error while running this script, I tried to modify it because I don't want it to be received on mail, I wanted the file to be save locally on my laptop. I am not really good with scripting, SO it would a really great help if you could share a script that can help me store this script locally.

Also, just wanted to know, if there is any significant effect seen on network or device performance while running this script.

Thanks,

Puneet

0 Kudos
punjain
Contributor
Contributor

Hi Marcus,

I managed to run the script, it runs fine, however in the html file there were no charts and pie diagrams I just see X marks on the images. Also, is it possible I can get a word file output for this stored locally because I may not have an smtp setup.

Thanks,

Puneet

0 Kudos
Ankojin
Contributor
Contributor

Hi Gravey,

I have changed that as you mentioned in below , However in vCenter Inventory its showing only datastores which are VMs , but In cluster wise report it showing local datastores also.

Could you please help me where can change that string in script.

Thanks,

Ankoji

0 Kudos