Automation

 View Only
Expand all | Collapse all

Get total number of disks configured on virtual VM

  • 1.  Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 09:41 AM

    Hi

    I'm unable to find a command to collect the total number of disks and the controller configured on VM?

    Can you help me at least with some resources  



  • 2.  RE: Get total number of disks configured on virtual VM
    Best Answer

    Posted Feb 02, 2023 09:49 AM

    You mean something like this?



  • 3.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 12:55 PM

    I tried to add it to this script but I'm getting errors

    https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/vSAN-policy-in-different-datastores/m-p/2951782#M110494

    for sure you can help me but I would like to understand how I can find such information, because I'm checking this 2 references

    https://developer.vmware.com/docs/powercli/latest/products/vmwarevsphereandvsan/
    https://developer.vmware.com/apis/1355/vsphere

    For sure I'm doing something in wrong way

     

     



  • 4.  RE: Get total number of disks configured on virtual VM
    Best Answer

    Posted Feb 02, 2023 01:07 PM

    Did you try something like this?

     



  • 5.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 02:39 PM

    As simple as that   Thank you

    Question : to have the output in separate line this , would you please help me with some clue, I would like to give a try

    lElOUCHE_79_0-1675348691281.png

     

     



  • 6.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 02:57 PM

    Instead of looking at al the Harddisks at once, I would loop over the Harddisks.
    Using a loop like this for example


    The PipelineVariable parameter allows you to refer to the objects returned by Get-VM, via $vm, and Get-Harddisk, via $hd.

    Also, note that the Get-View is not really needed, you can access the same properties via for example $vm.ExtensionData and $hd.ExtensionData



  • 7.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 03:21 PM

    I will give atry and keep you posted

    I'm still  beginner 



  • 8.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 05:11 PM

    We were all beginners at one point in time 
    The best way to learn is by doing



  • 9.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 06:41 PM

    would you please assist me to find reference where I can find ExtensionData?

    I checked the link below

    https://developer.vmware.com/docs/powercli/latest/products/vmwarevsphereandvsan/



  • 10.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 07:02 PM

    Sure, everything that is available under ExtensionData are in fact the objects listed in the vSphere Web Services API.

    For example the content you get when you do

    is documented under the VirtualMachine entry.
    Similar for $esx.ExtensionData, $datastore.ExtensionData, $datacenter.ExtensionData, ...

    Reading the API Reference might take a while to get used to, but everything is in there.

    The objects returned by cmdlets that use a REST API method are documented in the vSphere Automation Reference



  • 11.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 07:45 PM

    I tried something like this, the good point is that I didn't received any error message but the result is not what's expected

     

    The output for path for example it shot something like this */storage/autodeploy* and I was wondering that I will have the path for the datastore



  • 12.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 08:13 PM

    Everything under $vm.ExtensionData.Guest is information obtained by the VMware Tools from inside the Guest OS.
    The Guest OS has no knowledge whatsoever about the virtual environment, including datastores.

    That is one reason I suggested earlier to have a loop with Get-Harddisk.
    That will return vDisk information, including the Datastore



  • 13.  RE: Get total number of disks configured on virtual VM

    Posted Feb 02, 2023 08:22 PM

    Thanks I will try again