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
No related posts.

Alan
August 26th, 2008
Thats usefull, nice to publsih into an IIS site for manager/reporting type people to view the results
sTyLeR_1
August 26th, 2008
Hi Peeters,
very nice! and tnx for the job. this saved me a lot of work :)
admin
August 26th, 2008
You’re welcome.
If you have any other scripting requests, please don’t hesitate to ask.
Hugo
Matthias
August 27th, 2008
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
admin
August 27th, 2008
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
Matthias
August 28th, 2008
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
admin
August 28th, 2008
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…
admin
August 28th, 2008
DÓh, that should read inpuTobject.
admin
August 28th, 2008
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.
Matthias
August 28th, 2008
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
admin
August 28th, 2008
Matthias, see my corrections in other comments. Put the code from comment 9 in the script before $myCol+=$myObj
Hugo
Matthias
August 28th, 2008
Great!
It works!!! THX for your help!
Have a nice day!
sTyLeR_1
October 8th, 2008
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
:)
J. Le
February 17th, 2009
what is the syntax to run this script against a Virtual Center?
admin
February 17th, 2009
@J. Le
Just type the full path to the script file in your Powershell window.
Steve
April 1st, 2009
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
admin
April 1st, 2009
@Steve
Try replacing this:
$output = Read-Host “Output path\file”
With this:
$output = ‘D:\scripts\output.html’ # Use your path here
Steve
April 16th, 2009
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…
admin
May 4th, 2009
@Steve
Cool! Thank you for taking the time to comment on my website. I appreciate it.
You’re welcome.
Hugo