I get the error below in powershell when i try to execute the following commad:
Copy-VMGuestFile -LocalToGuest -VM $vm -GuestCredential $LocalCredentials -Source $LocalPath\* -Destination C:\SomePath\ConfigurationFiles\ -Force -Confirm:$false
However, this error below only seems consistent when the command is executed shortly after cloning and powering on a template VM. When i later execute the command manually, it seems to have no issues. When i power on the new VM i make sure to use Wait-Tools command. I am not quite sure how to interpret the stacktrace of this error, as it seems to occasionally work with identical parameters. Any help would be greatly appreciated! Kind regards Oliver O. Nielsen.
12-03-2021 12:48:16 Copy-VMGuestFile A specified parameter was not correct:
at ConfigureVirtualWindowsMachine, C:\SomeProject\Preprod\VMwareScripts.ps1: line 134
VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidArgument: 12-03-2021 12:48:16 Copy-VMGuestFile A specified parameter was not correct: ---> VMware.Vim.VimException: A specified parameter was not correct: ---> System.ServiceModel.FaultException: A specified parameter was not correct: Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at VimApi_67.VimPortType.ListFilesInGuest(ListFilesInGuestRequest request) at VMware.Vim.GuestFileManager.ListFilesInGuest(ManagedObjectReference vm, GuestAuthentication auth, String filePath, Nullable`1 index, Nullable`1 maxResults, String matchPattern) --- End of inner exception stack trace --- at VMware.Vim.GuestFileManager.ListFilesInGuest(ManagedObjectReference vm, GuestAuthentication auth, String filePath, Nullable`1 index, Nullable`1 maxResults, String matchPattern) at VMware.VimAutomation.ViCore.Impl.V1.VM.Guest.VixServiceFileSystem.PathExistsInGuest(String absolutePath, FileType& type) --- End of inner exception stack trace --- at VMware.VimAutomation.ViCore.Impl.V1.VM.Guest.VixServiceFileSystem.PathExistsInGuest(String absolutePath, FileType& type) at VMware.VimAutomation.ViCore.Impl.V1.VM.Guest.GuestFileSystem.CopyFromLocalToGuest(String absoluteSourcePath, String destination, Boolean force) at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.CopyGuestFile(VirtualMachineInterop vm, String source, String destination, String guestUserName, SecureString guestPassword, Boolean force, Boolean copyFromGuest, OSType osType, Boolean recursive) at VMware.VimAutomation.ViCore.Impl.V1.Service.VmGuestServiceImpl.CopyGuestFile(VirtualMachineInterop vm, String source, String destination, String guestUserName, SecureString guestPassword, Int32 toolsWaitSeconds, Boolean force, Boolean copyFromGuest) at VMware.VimAutomation.ViCore.Cmdlets.Commands.CopyVMGuestFile.DoWork(VIAutomation client, List`1 moList)
I have seen issues with Wait-Tools before.
In my experience, it is better to wait for $vm.ExtensionData.Guest.GuestOperationsReady
That is most of the time somewhat later than the VMware Tools showing the "running" state.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference