1 Reply Latest reply on Dec 3, 2013 7:04 AM by RvdNieuwendijk

    New-folder issue with subfolders

    Gabrie Master
    vExpert

      Hi

      Customer has quite an extensive structure of subfolders in the "VMs and templates" section. I have exported these from the existing vCenter to a CSV file and now want to import them into the new vCenter. But I'm running into an issue where the folder can't be created if the parentfolder isn't unique. Which I can understand. But I can't figure out how to refer to the non-unique parent folder in a different way.

       

      This is what I do and what works:

       

      New-Folder -Name "TOP" -Location "vm"

      New-Folder -Name "SUB-ONE" -Location "TOP"

      New-Folder -Name "SUB-TWO" -Location "SUB-ONE"

      New-Folder -Name "SECONDTOP" -Location "vm"

      New-Folder -Name "SUB-ONE" -Location "SECONDTOP"

       

       

      But when I now try to add a folder under TOP\SUB-ONE, there is no way to reference to it:

      New-Folder -Name "SUB-THREE" -Location "SUB-ONE"

      New-Folder -Name "SUB-THREE" -Location "TOP\SUB-ONE"

      New-Folder -Name "SUB-THREE" -Location "vm\TOP\SUB-ONE"

       

      All the above report:

      New-Folder : 12/3/2013 10:51:39 AMNew-Folder    VIContainer parameter: Could not find any of the obj

      ects specified by name.   

      At line:1 char:11

      + New-Folder <<<<  -Name "SUB-THREE" -Location "vm\TOP\SUB-ONE"

      + CategoryInfo      : ObjectNotFound: (VMware.VimAutom...tainer Location:RuntimePropertyInfo) [New-

         Folder], ObnRecordProcessingFailedException

      + FullyQualifiedErrorId : Core_ObnSelector_SetNewParameterValue_ObjectNotFoundCritical,VMware.VimAutoma

         tion.ViCore.Cmdlets.Commands.NewFolder

       

       

      Any help is appreciated.

      Gabrie

        • 1. Re: New-folder issue with subfolders
          RvdNieuwendijk Virtuoso
          User ModeratorsvExpert

          You can store all the folders in variables. Something like this:

           

          $FolderTOP = New-Folder -Name "TOP" -Location "vm"

          $FolderTOP_SUB-ONE = New-Folder -Name "SUB-ONE" -Location $FolderTOP

          $FolderTOP_SUB-ONE_SUB-TWO = New-Folder -Name "SUB-TWO" -Location $FolderTOP_SUB-ONE

          $FolderSecondTop = New-Folder -Name "SECONDTOP" -Location "vm"

          $FolderSecondTop_SUB-ONE = New-Folder -Name "SUB-ONE" -Location $FolderSecondTop

           

          $FolderTOP_SUB-ONE_SUB-THREE = New-Folder -Name "SUB-THREE" -Location $FolderTOP_SUB-ONE