# encoding: ascii
# api: powershell
# title: Step02b-Import-VM-to-Fol
# description: Import vCenter Folder structure incl VM relations
# version: 0.1
# type: function
# author: Leon Scheltema
# license: CC0
# x-poshcode-id: 5665
# x-archived: 2015-01-15T20:03:25
# x-published: 2015-01-07T12:16:00
#
#
# Import vCenter Folder structure incl VM relations
# By Leon Scheltema AVANCE ICT Groep Nederland
# Functions used by Grzegorz Kulikowski / Robert van den Nieuwendijk

# Begin variables
$NewVC = "New vCenter"
# End variables

# Connect to vCenter server
Connect-VIServer "$NewVC"

$vmlist = Import-Csv "migratedvms.csv"
move-vm -vm $vmlist[0].name -Location (get-view -id $vmlist[0].folder -Server $newVC|get-viobjectbyviview) -Server $NewVC

# Disconnect from vCenter server
Disconnect-VIServer -server "$NewVC" -Force -Confirm:$false
