VMware Cloud Community
jasonpadman
Contributor
Contributor

Copy-DatastoreItem with / in the Datacentre Name

Hi All,

I am trying to copy VM's VMDK files from VMware stores to my local C:\ computer and coming across a problem using the PowerCLI 5.1 cmdlet Copy-DatastoreItem when Data center has forward slash / in the name  e.g Data/Center. I have tried to use the escape sequence "%2f" to replace the / in the variable beforehand but for some reason it still does not work and get the same error saying it cannot find the source file. I have confirmed that my method works as I've been using this extensively with other DataCenters names without a forward slash /.

I have also tried Mapping the Datastore with a PS Drive with the New-PSDrive cmdlet and then trying to do the Copy-DatastoreItem but get the same error saying it cannot find the source vmdk file.

Copy-DatastoreItem : 2/08/2013 12:09:19 PM    Copy-DatastoreItem

Cannot find path 'vmstore:\Data %2fStore\TestDataStore\TestVM\TestVM.vmdk' because it does not exist.   

At F:\Scripts\copy-datastoreitemproblem.ps1:57 char:13

+ Copy-DatastoreItem -Item $VMwareSource -Destination $VMDK ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidArgument: (System.Object[]:Object[]) [Copy-DatastoreItem], VimException

    + FullyQualifiedErrorId : Core_CopyDatastoreItem_TryValidateSourceItem_InvalidSourceItem,VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyDatastoreItem

If anyone has any suggestions I could try I’d be very grateful to hear from you.

-Jason

0 Kudos
2 Replies
LucD
Leadership
Leadership

Did you try to escape the forward slash with the escape character (back-tick) ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jasonpadman
Contributor
Contributor

Hi LucD,

Thanks for getting back to me. Yes, I tried the escape character (back-tick) but forgot to mention it my last post. Good suggestion though!

0 Kudos