VMware Cloud Community
manak13
Contributor
Contributor
Jump to solution

Migrating vm's to a different folder using powercli

Hi Guys,

I am migrating some hosts between 2 different virtual centers and will have all incoming vm's on the new virtual center added to the "Discovered virtual machine" folder by default.  I am trying to use powercli to move the linux vm's to a specific folder and windows vm's to another folder.  However, I have been unable to do this and was hoping someone on here can help.  I am new to using powercli.  Here is what I have been trying:

Get-Datacenter "XXX" | Get-Folder "Discovered virtual machine" | get-vm | Where-Object {$_.PowerState -eq "PoweredOn"} | get-vmguest | Where-Object {$_.OSFullName -like "*Linux*"} | Move-VM -Destination "Linux"

Looks like move-vm does not like the input it is getting from get-vmguest.  However, it does like the input from get-vm but I can't seem to get a list of just linux vm's using the get-vm command.  Any help would be appreciated.

Thanks,

-Simran

0 Kudos
1 Solution

Accepted Solutions
kunaludapi
Expert
Expert
Jump to solution

Get-Datacenter "XXX" | Get-Folder "Discovered virtual machine" | get-vm | Where-Object {$_.PowerState -eq "PoweredOn" -and $_.ExtensionData.Config.GuestFullName -like "*Linux*"} | Move-VM -Destination "Linux"

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".

View solution in original post

0 Kudos
2 Replies
kunaludapi
Expert
Expert
Jump to solution

Get-Datacenter "XXX" | Get-Folder "Discovered virtual machine" | get-vm | Where-Object {$_.PowerState -eq "PoweredOn" -and $_.ExtensionData.Config.GuestFullName -like "*Linux*"} | Move-VM -Destination "Linux"

--------------------------------------------------------------- Kunal Udapi Sr. System Architect (Virtualization, Networking And Storage) http://vcloud-lab.com http://kunaludapi.blogspot.com VMWare vExpert 2014, 2015, 2016 If you found this or other information useful, please consider awarding points for "Correct" or "Helpful".
0 Kudos
manak13
Contributor
Contributor
Jump to solution

Thanks for your response.  That worked and was exactly what I was looking for.  Much appreciated!

Regards,

-Simran

0 Kudos