Recently we’ve had to revert to migrating a customer through cloning virtual machines to a lun on a ‘migration storage box’ after which we had to do an import in our vCenter environment. Normally I just Veeam for ease in the whole migration process but this time there were circumstances which prevented this. After decoupling the migration box and connecting it to our vCenter environment we had to import the virtual machines which seemed tedious to do for a lot of virtual machines. Espescially because I only knew the manual way to do this. Some googling helped me out by finding the VMX Raiders script by LucD which I partly reused in my own script below.

Since I didn’t feel like entering the variables all the time I converted the script to a function. This function accepts the following parameters:

  • Clustername (Cluster in which the import has to take place)
  • Datastorename (Datastore that holds the unregistered VM’s)
  • VMFolder (Obviously the target for the import)

The script can also use the -WhatIf: and -Confirm parameters so that you can check what happends or receive a confirmation window. Just import the function into your PowerShell session and use it in the following format:

I’ve also added some verbose logging code into this function so that you can easily check if all the found unregistered virtual machines have been imported. To see it just enable it with the ‘-verbose’ parameter at the end of the function.

Want to see more automation scripts that we’ve made? Just click on the button below!

Leave a Reply

Your email address will not be published. Required fields are marked *