- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I upgraded the PowerCLI on my workstation (Win7/64) to 5.0.1 and got the same error - in attempt to rule out the workstation as a problem, I also installed PowerCLI 5.0.1 on a server (2k3/32) and got the same error as well.
If I remove the Export-CSV related code, the script runs (appears to take time to run, anyway) but has zero output.
Curious...
--- A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you get any output when you just display the results on screen ?
ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) { ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) { ForEach ($VM in ($Cluster | Get-VM | Sort-Object -Property Name)) { ForEach ($HardDisk in ($VM | Get-HardDisk | Sort-Object -Property Name)) { "" | Select-Object -Property @{N="VM";E={$VM.Name}},
@{N="Datacenter";E={$Datacenter.name}},
@{N="Cluster";E={$Cluster.Name}},
@{N="IP";E={[string]::Join(',',$VM.Guest.IPAddress)}},
@{N="Hard Disk";E={$HardDisk.Name}},
@{N="Datastore";E={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},
@{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}},
@{N="VMDKpath";E={$HardDisk.FileName}},
@{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name -contains $harddisk.filename.replace(".","-flat.")}).size/1GB}} } } } }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No output at all when run from the server or the 32-bit or 64-bit PowerCLI on my workstation.
--- A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And no error messages ?
Did you try the Get-Datacenter, Get-Cluster and Get-VM cmdlets seperately ?
Do they return anything ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No error message when I run the script without the Export-CSV.
Get-Datacenter produces expected output.
Get-Cluster shows nothing.
Get-VM produces expected output.
--- A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I think we're getting somewhere.
It looks as if you don't have any clusters in your datacenter(s).
This report will cycle through all the clusters, but since there are none, you will have no results.
You can leave out the Foreach loop for the clusters, then you should be getting the results for each VM in all your datacenters.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you so much!
Got it working - had to pull all references to $Cluster to get it running. Runtime took about 5 minutes, had me worried that things were locked up, but all is well.
Very, very cool... ![]()
Thanks again,
--- A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry for bring up such an old post but how do I use this script with import-csv as a input, I have a list of VM's in a CSV file that I want to find the used storage for. (note total storage utilsation not just VMDK sizes)
regards
Tom
VMware Communities User Moderator
Blog: http://www.planetvm.net
Contributing author on VMware vSphere and Virtual Infrastructure Security: Securing ESX and the Virtual Environment
Contributing author on VCP VMware Certified Professional on VSphere 4 Study Guide: Exam VCP-410
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The size is returning '0'.
I'll poke around to see what's what...any help would be appreciated.
(the vmdk's return fine - thanks for that...a big help!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Brilliant script thanks!! Does anyone know how to also list the logical folders that the VM's are in also please?
I am able to use the following in the vCLI;
$VMFolder = "Production"
Get-Folder $VMFolder | Get-VM
This shows me the production folder, but im trying to display all VM's and the folders they reside in, but i dont seem able to run it in the script.
Many thanks
Ian.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An option is to use the New-VIProperty cmdlet.
See the YellowFolderName property on my VIProperties page under VirtualMachine.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello everyone,
I'm having a hard time trying to get this script do what I want it to do.
I'd like to just add a column that shows the provisioned space for each drive. Currently the "VMDK Size" column will show the amount of space actually being used, but would like to output the provisioned size of the drive as well.
I'm a little new at this, I appreciate any help. Any thoughts?
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
One way of getting the allocated harddisk space is as follows
$vm | Select Name,
@{N="HD Space";E={$_.HardDisks | Measure-Object -Property CapacityGB -Sum | select -ExpandProperty Sum}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for the quick reply. So far I am not able to get this added to the script in this thread though. Not sure what I'm doing wrong.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That inner loop goes through all the harddisks.
Do you want the capacity per harddisk or the total for the VM ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
For each VM, idealy, one column would should how how big the hard drive is, and how much space is being used by that drive. E.G.:
| VM | Datacenter | Cluster | Hard Disk | Datastore | VMConfigFile | VMDKpath | VMDK Size | Drive Size |
| Data1 | DC1 | C1 | Hard disk 1 | DS2 | [DS2] ....vmx | [DS2] ....vmdk | 18.29669 | 40 |
| Data1 | DC1 | C1 | Hard disk 2 | SS1 | [SS1] ....vmx | [SS1] ....vmdk | 18.30292 | 60 |
| Data2 | DC2 | C2 | Hard disk 1 | SS1 | [SS1] ....vmx | [SS1] ....vmdk | 18.37966 | 40 |
Again, I appreciate your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try something like this
$VmInfo = ForEach ($Datacenter in (Get-Datacenter | Sort-Object -Property Name)) { ForEach ($Cluster in ($Datacenter | Get-Cluster | Sort-Object -Property Name)) { ForEach ($VM in ($Cluster | Get-VM | Sort-Object -Property Name)) { ForEach ($HardDisk in ($VM | Get-HardDisk | Sort-Object -Property Name)) { "" | Select-Object -Property @{N="VM";E={$VM.Name}},
@{N="Datacenter";E={$Datacenter.name}},
@{N="Cluster";E={$Cluster.Name}},
@{N="Hard Disk";E={$HardDisk.Name}},
@{N="Datastore";E={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},
@{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}},
@{N="VMDKpath";E={$HardDisk.FileName}},
@{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name -contains $harddisk.filename.replace(".","-flat.")}).size/1GB}},
@{N="Drive Size";E={$HardDisk.CapacityGB}} } } } } $VmInfo | Export-Csv -NoTypeInformation -UseCulture -Path "C:\VmInfo4.csv"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Unfortunately the column still returns blank.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Which PowerCLI version are you using ?
Do a
Get-PowerCLIVersion
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content