Hi,
I need to move VM to another folder,but vmware_guest could not support this.
Could you help on this?
Thanks,
Hi,
I need to move VM to another folder,but vmware_guest could not support this.
Could you help on this?
Thanks,
Best way to do this for the moment is to have ansible executing an powercli script
Example path given to the script : Test-Env/Linux/ProjectA
Powercli script :
`
$Separator = ‘/’
#Powercli don’t know how to handle a full path for a fodler… Need to artificialy get the end folder…
$root = Get-Datacenter
$root = Get-Inventory -Name “vm” -Location $root -NoRecursion
$Folderpath.Split($Separator) | %{
if((Get-Inventory -Location $root -NoRecursion | Select -ExpandProperty Name) -contains “vm”){
$root = Get-Inventory -Name “vm” -Location $root -NoRecursion }
else {
$root = Get-Inventory -Name $_ -Location $root -NoRecursion }
}
$EndFolder = $root | where {$_ -is [VMware.VimAutomation.ViCore.Impl.V1.Inventory.FolderImpl]}|%{
Get-Folder -Name $_.Name -Location $root.Parent -NoRecursion }
#Move the VM to the correct folder
Move-VM -VM $VM -InventoryLocation $EndFolder
`
If you have several datacenters in your VMware inventory, need to pass it as parameter also and change the code to
$root = Get-Datacenter "MyDatacenter"