Trying to find a quick way to import all the VM & Templates (aka BLUE Folders) from Site A to Site B. Each Site has its own vCenter with multiple "Datacenters" located inside. I just want all the folders and subfolders of one Datacenter.. Now that explained here's whats happening
Exporting Site A folders using this line of code is working perfectly:
Get-Datacenter "Datacenter1" | Get-Folder | Get-FolderPath | Export-Csv "C:\Scripts\learning\folders.csv" -NoTypeInformation
I get a nice CSV file with NAME and PATH headings with all the names and paths of each folder.
Now when I try to Create the folders at Site B, it doesnt work most of the time. All these failed:
Import-Csv $importlist -UseCulture | %{
New-Folder -Name $_."Name" -Location $_."Path"
}
Import-Csv $importlist -UseCulture | %{
New-Folder -Name $_."Name" -Location (Get-Folder -Name $_."Path")
}
Import-Csv $importlist -UseCulture | %{
New-Folder -Name $_."Name" -Location (Get-Datacenter "Datacenter1" | Get-Folder -Name $_."Path")
}
Now.. if I do that last script AND remove "DATACENTER1" from the cell in CSV file under Path, the root folders get created. Still no joy on the subfolders.
Now I have reviewed other code in other posts on this site. And several from "some of people who are on this site offen and wrote some books" (you know who you are ). None of them work for me. All I need is to have several hundred (yes hundred) folders created with multi-sub levels deep. Some case 5 or 6 levels deep.. IE: DATACENTER\VM\ROOT FOLDER\ SUB LEVEL1\SUB LEVEL2\SUB LEVEL3\SUB LEVEL4\ <here be vms>
Thanks,
Boston Tech Guy