VMware Cloud Community
BostonTechGuy
Enthusiast
Enthusiast
Jump to solution

Script to Import VMs from Datastores

Is there a quick way to import all the VMs on a datastore into a vCenter?  Some sort of browse for VMX files and import?

More to the point.  I have single Datastore that has been moved to a new location with about 100 VMs on it.  I want to import all the VMs on this single datastore to a single host at the new location.

Thanks,

Boston Tech Guy

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can specify the name of that 1 datastore in the $Datastores variable.

And if you change this line

$ESXHost= Get-Cluster$Cluster| Get-VMHost| select-First1

into

$ESXHost= Get-VMHost -Name MyEsx

it should do the trick.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

Have you checked my VMX Raiders Revisited post ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BostonTechGuy
Enthusiast
Enthusiast
Jump to solution

I have, different versions of it as well.  It keeps choking on a few points.  The trick is I want to import all the VMs (about 100) from one datastore to one host.  The Host has several datastores attached to it, I dont want to search them all.  Also the other hosts in the cluster are not ready to have this datastore added to it.  (Politics is the reason, not technology).

Thanks

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can specify the name of that 1 datastore in the $Datastores variable.

And if you change this line

$ESXHost= Get-Cluster$Cluster| Get-VMHost| select-First1

into

$ESXHost= Get-VMHost -Name MyEsx

it should do the trick.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
BostonTechGuy
Enthusiast
Enthusiast
Jump to solution

The changes I made we not exactly like above, but logically I thought they were.  I am going to go ahead and do the exact changes you have listed.

Thanks

0 Kudos
BostonTechGuy
Enthusiast
Enthusiast
Jump to solution

Luc, that was it.  I was so close with the changes on my own.  Only one line was off with my changes... I made the same mistake I did before.

For $ESXHost I had this line.

$ESXHost = "name of ESX Host"

Which doesnt mean anything for the script.  Uggg need to remember that.

Thanks!

Boston Tech Guy

0 Kudos