VMware Cloud Community
Kevin_Hamilton
Contributor
Contributor

Guests and hard disk details associated to them

Hello, is there a quick way to display all my guest vm's, hard disks and associated details for the hard disks that are associated with them. It would be nice to output this to a doc if poss any help appreciated.

Cheers

H

Reply
0 Kudos
5 Replies
halr9000
Commander
Commander

I was going to answer with a script, but you said the magic words "output this to a doc", so I'll point you to some great entries in the VI Toolkit contest which ended a couple of months ago:

-

-






[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Reply
0 Kudos
Kevin_Hamilton
Contributor
Contributor

Cheers Hal, I have got this excellant script of Alan's and use it for other bits. Only prob for my bit at the moment is that it doesn't actually cover the individual VM Guests and relevant Disks and capcities against each one. My scripting skills are basic at best. If you have a script that could help I would be most appreciative.

PS any news on when you are going to release your book.

Cheers

H

Reply
0 Kudos
halr9000
Commander
Commander

How about this:

PS > $hdCapacity = @{ N = "CapacityKB"; E = { $_.HardDisks | % { $_.CapacityKB } } }
PS > Get-VM | select Name, $hdCapacity | Format-Table -autosize

Name                                 CapacityKB
----                                 ----------
phatltest-bhaskar-RHEL5_SVM            12582912
New Virtual Machine                     1048576
phatldev-jwu-dev-01                    16777216

If you want to get freespace, then the Tools service must be running and you would do that this way:

PS > $hdCapacity = @{ N = "Capacity (bytes)"; E = { $_.Guest.Disks | % { $_.Capacity } } }

PS > $hdFreeSpace = @{ N = "FreeSpace (bytes)"; E = { $_.Guest.Disks | % { $_.FreeSpace } } }

PS > Get-VM | select Name, $hdCapacity, $hdFreeSpace

Name Capacity (bytes) FreeSpace (bytes)

-


-


-


phatlvc02 {8578932736, 10733957120} {837120000, 9870405632}

svustika_test1

phatltest-tdodd-01 8578932736 5101920256

phatldev-ssnyder-01 14508892160 2677510144

Note the 2nd VM here doesn't have the tools service running, so you see there is no response.

The output for these isn't ideal because a VM can of course have multiple HDs. It may need tweaking to fit your requirements.

And for my book, it's looking like 1Q09 to be on shelves.




[PowerShell MVP|https://mvp.support.microsoft.com/profile=5547F213-A069-45F8-B5D1-17E5BD3F362F], VI Toolkit forum moderator

Author of the upcoming book: Managing VMware Infrastructure with PowerShell

Co-Host, PowerScripting Podcast (http://powerscripting.net)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
Kevin_Hamilton
Contributor
Contributor

Thanks Hal, appreciate you taking the time to look at this for me. Will have a play with this.

Reply
0 Kudos
Rajeev_S
Expert
Expert

Hi

I tried "Report into MS Word" script. But it is giving me the attached error. Could any one guide.

Reply
0 Kudos