We are trying to create a script that will browse our LUNs and register my VM in an ESX host. I have a few FC LUNs and iSCSI LUNs. The problem is no I get an error message when it discover the Local VMFS volume.
The error is the followinng.
Exception calling "SearchDatastoreSubFolders_Task" with "2" argument(s): "Invalid datastore path '[http://bru03srvesx:storage1|http://bru03srvesx:storage1]'."
At :line:142 char:62
+ $TaskMoRef = $DatastoreBrowser.SearchDatastoreSubFolders_Task <<<< ($DatastorePath, $SearchSpec)
Does someone have an idea?
I think that line should say $FolderID instead of $folder.
... $FolderID.RegisterVM_Task($VMx,$matches[1],$FALSE,$ResourcePool.MoRef,$null) ...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
What's the exact string used as your datastore path? You might try to enclose it in noformat tags so the forum wiki formatting won't fudge it.
e.g.: [DATASTORE] /path/file.vmdk
Note there's a space betwixt the right bracket and the forward slash.
[vExpert|http://www.vmware.com/communities/vexpert/], PowerShell MVP, VI Toolkit forum moderator
Author of the book: Managing VMware Infrastructure with PowerShell
Co-Host, PowerScripting Podcast (http://powerscripting.net)
Need general, non-VMware-related PowerShell Help? Try the forums at PowerShellCommunity.org
I suspect you're using my script from ?
Since the forum SW, like Hal said above, has problems with square brackets, you better copy the script from the file that is attached in that thread instead of copying it from your browser.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thx for the feedback. I'll have a look...
Did you run the script in a VI 2.5 environment or in a vSPhere environment ?
There are other threads that reported problems with the SearchDatastoreSubFolders_Task method in vSPhere.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
It looks as if there is a bug with SearchDatastoreSubFolders_Task in vSphere.
See for a bypass.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello.
The VI environment is VI 3.5 U 1 and we are using the vSphere power CLI
Cheers,
JY
Ok, then the problem is not related to the SearchDatastoreSubFolders_Task bug in vSPhere.
Could you perhaps attach the script you're using ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
We could move one step further ...you were correct about the syntax...the SearchDatastoreSubFolders_Task works now...
We have a new error.I have attached the script we are creating for a mini disaster recovery. thx for ur help.
In the meantime I 'm trying ur register-vm.ps1 on our infra trying to see what we are missing.
You cannot call a method on a null-valued expression.
At :line:167 char:26
+ $Folder.RegisterVM_Task <<<< ($VMx,$matches[1],$FALSE,$ResourcePool.MoRef,$null)
I think that line should say $FolderID instead of $folder.
... $FolderID.RegisterVM_Task($VMx,$matches[1],$FALSE,$ResourcePool.MoRef,$null) ...
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello. Thx for your help. We are nearly done with the script and tmr we will test Thx a lot for your help.