Automation

 View Only
  • 1.  Use Copy-DatastoreItem is not working with vmdk files

    Posted May 23, 2024 04:21 AM

    Hallo 

    I wont to copy virtual machine data from a Windows local disk to a vsan datastore with Powershell. 

    In the first step I create a PSdrive. 

    As example: 

    New-PSDrive -Location (Get-Datastore -name $a.Datastore) -Name ds -PSProvider VimDatastore -Root "\"

    the next step is the copy procedure with "Copy-DatastoreItem". 

    As example: 

    Copy-DatastoreItem -Item ($path + "\VMs\" + $a.VMname + "\") -Recurse -Destination "ds:\" -force

    All files (apart VMDK) where copy to the vsan datastore. The folder for the VM was create automatically. 

    Only the files with ending *.vmdk can't copy. I've become an 500 (Internal Server Error).

    The same Problem is with Thin or Thick disk. Large file e.g. ISO file can copy to the Datastore. 

    Change the destination datastore to local datastore of an ESXi server has the same problem. 

    I've test the powercli connection to the vCenter or to the ESXi host. Both have the same failure. 

    As a workaround: 

    When I use thick disk and change the file extension to e.g. TXT, the copy process is working fine 

    Hav anybody the same problem and a solution? 

    Kind regards 

    Matthias 



  • 2.  RE: Use Copy-DatastoreItem is not working with vmdk files

    Posted May 23, 2024 05:37 AM

    Did you already try the Copy-Harddisk cmdlet instead for the VMDK?



    ------------------------------


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


    ------------------------------



  • 3.  RE: Use Copy-DatastoreItem is not working with vmdk files

    Posted May 23, 2024 08:57 AM

    copy-harddisk or get-harddisk could not work. 

    The VM is as file on a Windows local disk and not register to an ESXi host