PowerCLI

 View Only
  • 1.  Copy-VMGuestFile gives errors with new VMware Tools

    Posted Jan 23, 2020 12:35 PM

    Hi,

    Our VMops team who deploys new VMs has some scripting in place that after deployment of the VM, copies some files into the VM.

    They now run in to an error when doing a CopyVMGuestFile to a Windows 2019 VM with VMware Tools 11.0.5. Strangely enough other combinations DO work:

    - Win 2012 / Win 2016 with VMware Tools 11.0.5 = WORKS

    - Win 2012 / Win 2016 with VMware Tools 10.5 = WORKS

    - Win 2019 with VMware Tools 10.5 = WORKS

    - Win 2019 with VMware Tools 11.0.5 = DOESN'T WORK

    The command they run:

    Get-Item $SupportingFilesPath\* | Copy-VMGuestFile -Destination "C:\Temp\" -vm $VM_Deploy.DEP_VmName -localtoguest -GuestUser $Cred_LocalAdmin.UserName -GuestPassword $Cred_LocalAdmin.Password

    The error:

    Warning after command:

    WARNING: The guest OS for the virtual machine 'xxxx' is unknown. The operation may fail.

    Powercli exception:

    Copy-VMGuestFile : 23-1-2020 10:32:03   Copy-VMGuestFile                A specified parameter was not correct.

    At line:1 char:35

    + ... lesPath\* | Copy-VMGuestFile -Destination "C:\Temp\" -vm $VM_Deploy.D ...

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

        + CategoryInfo          : NotSpecified: (:) [Copy-VMGuestFile], InvalidArgument

        + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_DirectoryExistsInGuest_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Copy

       VMGuestFile

    Any ideas?

    Gabrie



  • 2.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Jan 23, 2020 03:03 PM

    Does Get-Item $SupportingFilesPath\* work?

    you may need to try:

    Get-Item "$SupportingFilesPath\*.*" | Copy-VMGuestFile -Destination "C:\Temp\" -vm $VM_Deploy.DEP_VmName -localtoguest -GuestUser $Cred_LocalAdmin.UserName -GuestPassword $Cred_LocalAdmin.Password



  • 3.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Jan 29, 2020 10:34 AM

    That doesn't make a difference.



  • 4.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 20, 2020 08:53 PM

    Which PowerCLI version are you using?
    And in which PowerShell version is the script running?



  • 5.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 21, 2020 07:18 AM

    Running Copy-VMGuestFile from:

    PSVersion 5.1.17763.1432

    VMware PowerCLI 12.1.0 build 17009493

    The Destination VM

    PSVersion 5.1.17763.1490

    VMware Tools 11.2.0

    Microsoft Windows Server 2019 Datacenter

    Version 10.0.17763



  • 6.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 21, 2020 09:15 AM

    Since VMware Tools 11.2 is only out for 6 days, I'm not installing that (yet).

    But I just tried with a Windows 2019 server that has VMware Tools 11.1.1, and the Copy-VMGuestFile (from PowerCLI 12.1) operation works without a problem (in both directions).



  • 7.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 22, 2020 02:26 PM

    I'm pretty sure the issue is with ESXi 6.5 version and the newer version of tools, the host is missing some patches. Seems okay on another updated host.

    I'm sure Copy-VMGuestFile used to create the folder but I do get a proper error if its missing on updated host "The destination 'c:\Temp\' does not exist on VM"



  • 8.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Jun 10, 2021 09:28 PM

    I'm having this problem as well.

    I create the VM with New-VM

    Wait for the VM to be ready, checking $VM.ExtensionData.Guest.GuestOperationsReady -ne $true in a loop.

    Once ready, attempt to copy a file to the VM from the local host.

    Copy-VMGuestFile -LocalToGuest -Source "$PSScriptRoot\myfile.txt" -Destination "c:\myfile.txt" -force @CredArgs

    Copy fails with the same error as OP.

    I put the copy into a retry loop. On each failure I print GuestOperationsReady and guestheartbeatstatus.

    GuestOperationsReady True, HeartBeat: gray

    The loop succeeded after about 17 seconds.


    At the same time in the VCenter UI, the DNSName and IPAddress got refreshed.

     

        $counter = 0
        while ($counter -lt 100) {
            try
            {
                Copy-VMGuestFile -LocalToGuest -Source "$PSScriptRoot\file.txt" -Destination "c:\file.txt" -force @CredArgs
                break
            }
            catch
            {
                Write-Host "GuestOperationsReady $($VM.ExtensionData.Guest.GuestOperationsReady), HeartBeat: $($vm.extensiondata.guestheartbeatstatus)"
                Start-Sleep -seconds 1
                $counter += 1
                $ignore = $VM.ExtensionData.UpdateViewData("Guest.GuestOperationsReady") # Is this neccessary?
                $VM = Get-VM $VMName
            }
        }
        $VM = Get-VM $VMName
        Write-Host "GuestOperationsReady $($VM.ExtensionData.Guest.GuestOperationsReady), HeartBeat: $($vm.extensiondata.guestheartbeatstatus)"
    
    

     



  • 9.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 20, 2020 05:27 PM

    I have a very similar issue.

    The destination folder must exist in the VM then the file copy works, but the file name gets !% added to the start.

    Issue exists with VMware tools 11.0.6 and 11.2.0, pretty sure it was working in 10.2.1



  • 10.  RE: Copy-VMGuestFile gives errors with new VMware Tools

    Posted Oct 20, 2020 08:42 PM

    Moderator: Thread moved to the PowerCLI area.