VMware Cloud Community
jyvesd
Enthusiast
Enthusiast
Jump to solution

Exception calling "SearchDatastoreSubFolders_Task" with "2" argument(s)

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?

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
10 Replies
halr9000
Commander
Commander
Jump to solution

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

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000
LucD
Leadership
Leadership
Jump to solution

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

jyvesd
Enthusiast
Enthusiast
Jump to solution

thx for the feedback. I'll have a look...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
jyvesd
Enthusiast
Enthusiast
Jump to solution

Hello.

The VI environment is VI 3.5 U 1 and we are using the vSphere power CLI

Cheers,

JY

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
jyvesd
Enthusiast
Enthusiast
Jump to solution

We could move one step further Smiley Happy ...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)

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
jyvesd
Enthusiast
Enthusiast
Jump to solution

Hello. Thx for your help. We are nearly done with the script and tmr we will test Smiley Happy Thx a lot for your help.

0 Kudos