PeetersOnline.nl
Helpful scripts of the day: HTML Overview of VMs and Datastores
Today’s helpful scripts are ready to use scripts that generate an overview of your VM’s and your Datastores and save it to a HTML file. Great for reporting purposes. Easy to modify to meet your needs. Give them a try:
Get-DatastoreSizes (Rename to .ps1)
This one shows datastores with Used Space in GB, Free Space in GB and % Free Space.
This one shows vm’s with OS Name, Total Disk Size in GB and Memory Size in GB.
Enjoy!
Hugo
Tagged with: ConvertTo-HTML • datastores • overview • PowerCLI • PowerShell • reporting • VI Toolkit • vms • VMware
19 Responses to Helpful scripts of the day: HTML Overview of VMs and Datastores
Tags
Active Directory API bind order cleanup cluster CPU Custom Fields datastores description device management directory tree errors Event Log file name filter Fun function HA IT known issues License Server LUN multipath NIC objects Oneliner portgroups PowerCLI PowerShell profile recursive Registry Scripts security session share snapshots SQL Stat VI Toolkit VMware vSphere WMI WSUS ZenArchives
- July 2012
- July 2011
- February 2011
- January 2011
- December 2010
- May 2010
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008





Thats usefull, nice to publsih into an IIS site for manager/reporting type people to view the results
Hi Peeters,
very nice! and tnx for the job. this saved me a lot of work
You’re welcome.
If you have any other scripting requests, please don’t hesitate to ask.
Hugo
Hello from Germany! THX for your very usefull script! Excellent Job! I modified your script for my use a little bit but I can’t manage it to give me the Ip Adress of the VM. Can you give me a hint ? That would be very appreciated !
Matthias
Hi Matthias, and welcome to my blog!
The IP-address can be found in $VM.Guest.IPAddress
Note that it requires the VMware Tools to be installed and running to grab the values. In case of multiple IP’s, the property will contain an array with the IP-addresses.
Hope this helps,
Hugo
»crosslinked«
Hi Hugo! Thx for your quick reply. Well, I tried it like you said before, but I didn’t work. The output is==> System.String[]
I guess that means, that the requested data is inside an array. How can I get the information out of the array??
Matthias
Matthias,
Ah, I see what you mean.
That’s a bit tricky, because you will have to loop through all values of the array and add a property for each one. Here’s how it goes:
For ($i=0;$i -lt $VM.Guest.IPAddress.Length;$i++){Add-Member -InpuObject $myObj -MemberType NoteProperty -Name “IP$i” -Value $VM.Guest.IPAddress[$i]}
Hope that works…
DÓh, that should read inpuTobject.
Ah. One more mistake. It will only show one IP address column, because not all vms will have the IP1 or IP2 property. Heres a fixed version:
For ($i=0;$i -lt 4;$i++){Add-Member -InputObject $myObj -MemberType NoteProperty -Name “IP$i” -Value $VM.Guest.IPAddress[$i]}
The number 4 will cause each VM to have 4 IP properties, which will be blank if they have less IPs.
Hugo,
Yes that’s working! Good Job ! THX for your help! Any prefered position for *FOR* routine? So far it works, but I get only one IP Adress
Matthias
BTW: it’s called ==> InputObject
Matthias, see my corrections in other comments. Put the code from comment 9 in the script before $myCol+=$myObj
Hugo
Great!
It works!!! THX for your help!
Have a nice day!
hi,
for now i got:
$VC = Connect-VIServer (Read-Host “VC Server”)
$VMs = Get-VM | Where {$_.PowerState -eq “PoweredOn”}
$myCol = @()
ForEach ($VM in $VMs)
{
$myObj = “” | Select-Object Name, OS, DisksGB, MemGB, NumCpu
$myObj.Name = $VM.Name
$myObj.OS = $VM.Guest.OSFullName
$myObj.DisksGB = [Math]::Round((($VM.HardDisks | Measure-Object -Property CapacityKB -Sum).Sum * 1KB / 1GB),2)
$myObj.MemGB = [Math]::Round(($VM.MemoryMB * 1MB / 1GB),2)
$myObj.NumCpu = $VM.numCpu
For ($i=0;$i -lt 4;$i++){Add-Member -InputObject $myObj -MemberType NoteProperty -Name “IP$i” -Value $VM.Guest.IPAddress[$i]}
$myCol += $myObj
}
$myCol | Sort-Object Name | Export-Csv “VMs.csv” -NoTypeInformation
Can we add the following:
Hostname
ToolsStatus
ToolsVersion
And maybe give a choice menu in the beginning:
1. Report vm’s Powered On
2. Report vm’s Powered Off
3. Report all vm’s
what is the syntax to run this script against a Virtual Center?
@J. Le
Just type the full path to the script file in your Powershell window.
Hi Peeters,
Thank you very much for sharing this – One problem I am having is that when I run the script from the VI Toolkit window, I get an “access denied” for the destination output file directory. Might you be able to tell me what I’m doing wrong?
Thank you,
Steve
@Steve
Try replacing this:
$output = Read-Host “Output path\file”
With this:
$output = ‘D:\scripts\output.html’ # Use your path here
Thank you so much! I can’t begin to tell you how significant your work has been in helping me to launch our vmware environment…
@Steve
Cool! Thank you for taking the time to comment on my website. I appreciate it.
You’re welcome.
Hugo