Powershell脚本“ $ _。FullName”不起作用-通过“ Copy-VMFile”发送文件

问题描述 投票:0回答:1

我正在尝试使用我在Internet上找到的脚本来复制目录中的所有文件,但无法正常工作。有人可以帮忙调试吗?我猜该脚本用于传输Windows / Windows,但我需要Windows-> Linux。

https://www.powershellmagazine.com/2013/12/17/pstip-copying-folders-using-copy-vmfile-cmdlet-in-windows-server-2012-r2-hyper-v/

Get-ChildItem C:\tmp -Recurse -File | % { Copy-VMFile -Name "OpenProject8.3" -SourcePath $_.FullName -DestinationPath "/tmp/" -FileSource Host }

问题似乎与源路径有关,但不是100%。

Copy-VMFile : Failed to initiate copying files to the guest.
Failed to copy the source file 'C:\tmp\svn-repositories-20200212010002.tar.gz' to the destination '/tmp/' in the guest.
At line:1 char:43
+ ... -File | % { Copy-VMFile -Name "OpenProject8.3" -SourcePath $_.FullNam ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-VMFile], VirtualizationException
    + FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.CopyVMFile
powershell hyper-v
1个回答
0
投票

嗯。...我觉得很蠢!问题是早期的x-fer测试成功了,然后当文件存在时,Copy-VMFile不会覆盖文件(即使它使用root帐户...),并给出非描述性错误!上面的代码可以正常使用。

© www.soinside.com 2019 - 2024. All rights reserved.