VMware Cloud Community
RavindraReddy
Enthusiast
Enthusiast

How To Export the VM's List with the Folder Name which they are in ??

Hi All,

   We have created hirarchical folders in inventory , as per the application and location.  i would like to export the VM list with the folder name which they are in ( multiple folders if there). Could you please let me if any one know the procedure or any tool for the same.

We have hundreds of folders in the inventory , it geting very difficult for me to get the list folderwise.

Thank You ...

RR

0 Kudos
5 Replies
Alim786
Expert
Expert

Hi RR

I am sure RVTools can give you this and more - http://www.robware.net/

You can export all the information into csv or excel formats. I hope this helps.

VCP6-DCV, VCP5, CCNA, MCTS 2008R2, MCSA 2008R2, CCA, ITIL. Please mark answer helpful or correct as appropriate.
0 Kudos
Dave_Mishchenko
Immortal
Immortal

You could do this with PowerCLI using the New-VIProperty cmdlet.   The below sample, curtesy of LucD,  creates the new property FullFolderPath.   The properties for a VM object contains a foldername, but it isn't the full folder path so you wouldn't be able to distinguish between duplicate folders.  So if you were to run get-vm | ft name, folder  it wouldn't be too helpful.

New-VIProperty -Name 'FullFolderPath' -ObjectType 'VirtualMachine' -Value {
    param($vm)

    function Get-ParentName{
        param($object)

        if($object.Folder){
            $blue = Get-ParentName $object.Folder
            $name = $object.Folder.Name
        }
        elseif($object.Parent -and $object.Parent.GetType().Name -like "Folder*"){
            $blue = Get-ParentName $object.Parent
            $name = $object.Parent.Name
        }
        elseif($object.ParentFolder){
            $blue = Get-ParentName $object.ParentFolder
            $name = $object.ParentFolder.Name
        }
        if("vm","Datacenters" -notcontains $name){
            $blue + "/" + $name
        }
        else{
            $blue
        }
    }

    (Get-ParentName $vm).Remove(0,1)
} -Force | Out-Null

So you would first run the above code in your PowerCLI session.  What you create with New-VIProperty only exists for that PowerCLI session.  Once you close it, the new property is gone.

The you can run  get-vm | ft name, fullfolderpath

Name                                                        FullFolderPath
----                                                        --------------
MAIL01
WINDOWS07
EXCHANGE01
SERVER01                                               /Production
DC09                                                       /Production
VCENTER_01                                           /Production
QUICKTAX                                               /Taxes
vMA5.0
QUICKTAX_BACKUP_PRE2012_TAXES           /Taxes/Backup

One thing to note about the output.  In the case of the first few VMs, those are not in a VM folder.  For the vMA5.0 VM,  it is a vApp.

0 Kudos
RavindraReddy
Enthusiast
Enthusiast

Thanks Dave ... I am not that good in CLI , i will try with this. Smiley Happy

0 Kudos
RavindraReddy
Enthusiast
Enthusiast

Thank You..... Alim.

It didnt give the result what i was looking for , but great tool which i was not aware. Thank You for that Smiley Happy 

0 Kudos
Alim786
Expert
Expert

I'm glad it was helpful.Smiley Happy

VCP6-DCV, VCP5, CCNA, MCTS 2008R2, MCSA 2008R2, CCA, ITIL. Please mark answer helpful or correct as appropriate.
0 Kudos