Another way to gather VMware disk info with Powershell

I’ve created another way to gather and display VMware Virtual Disk information with the Powershell VI Toolkit.

The attached script generates a csv-file with all Virtual Machines’ Disks, in which Datastore they are stored, the LUN IDs of the extents that make up this Datastore (in HEX) and the Vendor of the SAN those LUNs are on (just in case you have multiple). Simpy a great way to determine which LUNs are used by which virtual server(s) in a complex environment.

diskinfo

By the way: the script is filled with comments to allow you to learn how it works.

create-vmdiskoverview (Rename to .ps1)

Enjoy!

Hugo

»crosslinked«

//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js

(adsbygoogle = window.adsbygoogle || []).push({});

In today’s deep analysis, we look at a rare small cap name that I hold both within my Biotech Forum and Insiders Forum portfolio, as this small biopharma focusing on pain management has a very attractive risk/reward profile at its current trading levels as well as heavy insider buying in 2016. It’s the Superman IV of the Batman movies, such a watershed of terrible moviemaking that no one would ever dare speak in its favor.. With the advantage of hindsight, we might wonder why these couples didn’t immediately start running when presented with what is clearly a rape van. The discussions are at an early stage, and Honest hasn’t ruled out going for an initial public offering instead. So we’ve taken a look back at the most unexpected news stories in Super Bowl history to try to predict this year’s unpredictable winner.. Manning’s numbers have dropped (he threw nine touchdowns and 17 interceptions in 10 games during the regular season, a far cry from his hall of fame worthy career stats), and his health and arm strength have been concerns. There’s more. In 2014, Super Bowl winners pocketed an extra $92,000. In the book, I go into six sets of issues with which we’ve constantly had to deal with the Russians, starting off with the nuclear legacy, with the proliferation of weapons of mass Baratas Replicas Ray Ban destruction, disagreements Fake Oakley Outle with Russia over the post Soviet space (which is obviously very much on display today in Ukraine),the question of Euro Atlantic security architecture (NATO and EU enlargement and the Russian response to that),then domestic Russian politics and more recently with all the upheaval in the Arab world.. “Coach Pete Carroll was an outstanding speaker who was perfect for our audience. I grate what appears to be about 3 ish tsp of grated onion, but I eyeball it. Notice how some people have a straight hairline and others might have oakley sunglasses outlet a widow’s peak? Let’s get to the root of that. Throughout the Holocene, according to UNEP, “based on the incomplete evidence available, it is unlikely that global mean temperatures have varied by more than 1C [2F] in a century.”. What’s your first point. Figure 2a c plots the T dependence of resistivity variation at H=0T for the L10 MnAl films, which shows distinct signatures associated with the TLS induced 2CK effect. As the game of baseball http://www.cheap-nfl-nike-jerseys.com has grown and become more international so has scouting. Strained muscles should be treated by applying ice for 20 minutes every hour while awake. Right now is anyway but this is no ordinary rookie. Cheap Jerseys But Cheap Jerseys DSS has significant upside from IP monetization activities, and that www.buyoakleysunglasses.com potential value is not reflected in the current $1.1/share..

28 thoughts on “Another way to gather VMware disk info with Powershell”

  1. @NiTRo
    NiTRo,
    Adjust the following line:
    Select VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object

    Replace it with this:
    Select VMHost, VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object

    And add the following line below it:
    $myObj.VMHost = $VMHost.Name # ESX Server Name

    Thanks,
    Hugo

  2. Pingback: Another way to gather VMware disk info with Powershell « H9Newser’s Blog
  3. @David
    @David
    Easy! Just modify this line:
    Select VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object
    Change it into this:
    Select VM, Description, Disk, DiskSizeGB, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object
    And add this line below it:
    $myObj.DiskSizeGB = [math]::Round(($DISK.CapacityKB * 1KB / 1GB),0) #Disk Size

    Hugo

  4. Is there any way for RDMs to show up as RDMs? I noticed they show up as virtual disks on the datastore in which the mapping file exists. Wondering if there’s a way to dive deeper, and identify these as RDMs and indicate LUN ID. Also, any good resources for VI-Toolkit education? Been googling, but resources are limited. Thanks.

  5. Hugo,

    This script is great. It gives me almost everything I need… there is one thing I would like. I would like to add a column for the name of the VMDK as well. Being a newbie at scripting… is that possible?

  6. @Eric
    Modify this line:
    Select VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object
    into:
    Select VM, Description, Disk, Datastore, VMDK, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object

    Add the following line below that line:
    $myObj.VMDK = $DISK.Filename.Split(“/”)[1]

    1. Going off of the Question from Hugo on 1/27, is there a way to give the “used” space of the guest’s VMDK? I’m trying to monitor the growth on a differential disk of link-cloned VDI guests.

  7. Hugo,

    Great script, thank you. But when I run it scripts runs for number of minutes and than I got

    ————————–
    You cannot call a method on a null-valued expression.
    At :line:29 char:41
    + $myObj.Datastore = $DISK.Filename.Split <<<< (“[]”)[1] # Datastore Name

    ————————–

    and no csv file is created.

  8. @invisible I’m guessing you have $ErrorActionPreference set to “Stop”. Try setting: $ErrorActionPreference = “Continue”. You will still see a lot of errors, but the script will finish.
    The reason for this script to generate errors, is that is assumes three disks are present in each and eveny vm. I had to pick a number and keep it the same for all the vm’s, because of difficulties displaying irregular information. Anyway, let me know if this helps.
    Hugo

  9. This script is very useful. I how do you change the number of present disks that the script scans for from 3 to 4? We have various VMs with more than 3 virtual disks. Thanks!

  10. @Harm
    The script does loop through ALL your disks. Only problem if you have more than 4 extents in a datastore. Then you should add hexLUN… to the following line:

    Modify line:
    Select VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, SAN # Create output object

    Into: Select VM, Description, Disk, Datastore, hexLUN0, hexLUN1, hexLUN2, hexLUN3, hexLUN4, SAN # Create output object

    Etc.

    Hugo

  11. Hi Hugo,

    firstly, a great script! Can I also add a column for the datacenter? I am also new with powershell and scripting in general and I didn’t find anything about $myObj.* and the “Select” part in your script.
    Thanks.

  12. @Michael
    I use “$myObj = “” | Select Name, Etc” to create custom objects to hold the output of my scripts. Read more here: http://www.peetersonline.nl/?s=advice
    You could add an outer loop doing ForEach ($Datacenter in Get-datacenter){…} and add a property named $myObj.Datacenter with the value $Datacenter.Name.
    Read some of the scripts on my site to get some feeling on how this works.
    Hugo

  13. Hi Hugo,
    I also wish I can get a field value from the Disk path or disk drive letter, do you know if it is possible ?

    Thanks

  14. Hi Hugo,

    Could you give me an example of an outer loop to get the cluster that each VM is connected to. For some reason my loop doesn’t end.

    Thanks!

  15. Script ran and listed the VMs but the hexLUN0 field = 0 for all vm’s and the rest of the hexLUN# fields are blank. The disks that aren’t listing properly are physical compatibility mode RDM drives….

    Any ideas?

Leave a Reply