PowerCLI

 View Only
  • 1.  List VMs with their Blue Folder Path

    Posted Jul 26, 2012 03:23 AM

    I need to get an Excel list of all VMs in my vCenter 5.0 and their Blue Folder location from the VMs and Templates view. For ex:

    Name     Folder

    VM1       datacenter\folder1\VM1

    VM2       datacenter\folder1\folder2\VM2

    VM3       datacenter\folder3\VM3

    VM4       datacenter\folder4\folder5\VM4

    VM5       datacenter\folder6\VM5

    I have tried several scripts posted on the forums but they never work right. Please advise,

    Thank you!



  • 2.  RE: List VMs with their Blue Folder Path

    Posted Jul 26, 2012 05:57 AM

    Which ones did you try ?

    And what goes wrong ?

    Did you also check Trying Get Folder Path for VM in VC... ?

    It resturns yellow and blue folders



  • 3.  RE: List VMs with their Blue Folder Path

    Posted Jul 26, 2012 03:32 PM

    I tried several of your scripts but the only one that produced any results was the one below. However, it still does not show the folder path, it shows the VMname instead...

    Your script:

    Connect-VIServer vc.local
    $report = @()
    foreach($vm in Get-VM){
        $parent = $vm.Folder
        $path = $vm.Name
        while ($parent){
            $path = $parent.Name + "/" + $path
            $parent = $parent.Parent
        }
        $row = "" | Select VM,Path
        $row.VM = $vm.Name
        $row.Path = $path
        $report += $row
    }
    $report

    Results:

    VM   : W2003x86v1-1-Temp

    Path : W2003x86v1-1-Temp

    VM   : 000088-Config19VM3

    Path : 000088-Config19VM3

    http://communities.vmware.com/thread/309096



  • 4.  RE: List VMs with their Blue Folder Path

    Posted Jul 26, 2012 04:52 PM

    Strange, that seems to work for me.

    Under the VMs and Templates tab, you do have blue folders ?

    And they are all under the datacenter(s) ?

    Otherwise include a screenshot so I can have an idea how your VMs and Templates looks.



  • 5.  RE: List VMs with their Blue Folder Path

    Posted Jul 26, 2012 07:02 PM

    I think I found my problem... I was using PowerCLI 4.0 on this box so I upgraded it to 4.1 and it works just fine now. Ex:

    Name : FixWeb1
    Path : Datacenters/ETC/host/ETCFZ1TST01/Resources/Testing/FixWeb1

    I also tried another one of your scripts and it works as well. http://communities.vmware.com/message/1828709 Ex:

    NameBlueFolderPath
    W2003x86v1-1-Temp/Infrastructure/Templates/Test Farm

    Thank you for your help!!