Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 229247

Re: Creating Folder Structure

$
0
0

The New-Folder cmdlet unfortunately doesn't allow to specify a folderpath for the Location parameter.

But you could try something like this

 

$root=Get-Folder-NameDatacenters
Import-Csv$importlist-UseCulture|
Sort-Object-Property {(Select-String-InputObject$_.Path-Pattern'/+'-AllMatches).Matches.Count} |%{
   
$location=$root
   
$qualifiers=$_.Path.Split('/')
   
$qualifiers[0..($qualifiers.Count-2)] |%{
       
$location=Get-Inventory-Name$_-Location$location
    }
   
New-Folder-Name$qualfiers[-1] -Location$location
}

 

We start in the 'root' of the vCenter.

The script first take the folders with shortest path.

It follows all the qualifiers in the Path, except for the last one, which is the new folder.


Viewing all articles
Browse latest Browse all 229247

Trending Articles