I have a script that I developed to deploy VMs from templates. In the script I do quite a bit on analysis to determine the best Host/Datastore/Cluster to place the new VMs in.
Everything works great when run synchronously, but I have now added code to allow me to run multiple deployments at once, but in order to do this, I need to utilize the Start-Job command.
The problem appears to be that when the arguments which include vCenter objects (host, datastore, cluster, template, custspec, folder) are passed into the start-job command, they fail to execute.
My only resolution to this point is to pull the .Name value from all of those objects when I pass them and re-gather the objects after the job starts. Not especially efficient if you ask me.
Attached is all of the relevant information… As you can see, I have to pass strings instead of objects as for some reason, passing objects doesn’t work. Gathering the objects twice seems inefficient and I would like to figure out what I am doing wrong.