Powershell 脚本“$_.FullName”不工作 - 通过 "Copy-VMFile" 发送文件

Powershell Script "$_.FullName" not working - Sending files via "Copy-VMFile"

我正在尝试使用我在 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

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