Brilliant!
I see that it's correctly locating our network storage device, and I see the correct number of tasks sent to VIC, but now I'm getting this error:
In VIC, the status of each of the tasks reports " " is invalid or too long." (yeah, the status begins with a double-quote)
In the script editor under locals, i've located this:
$file.DynamicType -- Cannot process argument because the value of "obj" is null. Change the value of argument "obj" to a non-null value."
$file.DynamicProperty -- Cannot process argument because the value of "obj" is null. Change the value of argument "obj" to a non-null value."
$file.File[0].DynamicType -- Cannot process argument because the value of "obj" is null. Change the value of argument "obj" to a non-null value."
$file.File[0].DynamicProperty -- Cannot process argument because the value of "obj" is null. Change the value of argument "obj" to a non-null value."
These values don't appear directly accessible via the script, are these values returned by the SDK functions you mentioned? Or, rather, null returns of an SDK function? :P
Setting any of those to "1" didn't seem to help either, except in doing so, I only received the error on $file.DynamicType and $file.DynamicProperty. Does that make sense?
I figured it was worth a shot :P
So to reiterate -- the script locates all the vmx's properly, sends the task to VIC, but it looks like there is a bit of data missing ...
(edit)
Oh wait .. I've received that error on more than just those four keys ... on second glance, it looks like those errors are to be expected because some of those values are useless. For example, for the variable $searchspec, everything except $searchspec.matchpattern gets the same error mentioned above. It's obvious in the script that .matchpattern is the only one we are explicitly defining ... so any other ideas on why VIC doesn't like the task?
(edit again twice here sorry)
Ok I've officially really confused myself. My head hurts.
I noticed that the value of $vmx at the end of the script had the path up to the vmx, but did not include the filename! After some playing with it, VIC did in fact add one VM, with the name "cp_vms", which just happens to be the name of the resource pool they are supposed to be part of. Obviously, when it tried to add all the other vms, it errored with "The name 'cp_vms' already exists.
So I started over fresh with your script again to see what I could do.
So the first thing that confused me was that two variables were defined with different names. It looks like PowerTools will cover the user in this case, and just define the values for each variation of the same variable name. In this case, $searchspec, $searchSpec, $datastorepath, and $datastorePath were all defined, all with the same values according to the 'locals' section. I tried cleaning that up ... but it didn't seem to help.
Also, what is $res for? I see it defined, but it's not utilized anywhere. Is it used by $folder.RegisterVM_Task() by chance? Am I trying too hard?!? :P
And one last thing .. the values I changed to fit our environment were: VIserver, the vmhost, the name of the datacenter, the name of the cluster, and the name of the resource pool. I did not change the name of the folder, because I wasn't really sure how this part was relevant. I tried running a few variations from the command like of what I thought that value 'should' be, but failed miserably :\
Does that value need to be changed as well?
Thanks again for any assistance ... sorry to be such a newb, I'm trying! :P