【发布时间】:2020-07-01 19:56:54
【问题描述】:
我运行这些 PowerShell 命令的机器是 Ubuntu 18.04 机器,但是当从另一台 Windows 机器运行时,这种行为仍然存在。 我试图通过 Invoke-Command cmdlet 远程执行命令以将文件从 C:\ 复制到映射的网络设备 \\name\share\,但我经常收到此错误:
PS /home/appadmin> Invoke-Command -ComputerName x.x.x.x -ScriptBlock {Copy-Item -Path C:\Directory -Destination \\name\share\ -Recurse -Force} -Credential $cred -Authentication Negotiate
The path is not of a legal form.
+ CategoryInfo : InvalidArgument: (\\name\share\:String) [Copy-Item], ArgumentException
+ FullyQualifiedErrorId : CreateDirectoryArgumentError,Microsoft.PowerShell.Commands.CopyItemCommand
+ PSComputerName : x.x.x.x
The handle is invalid.
+ CategoryInfo : WriteError: (File.vhdx:FileInfo) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyDirectoryInfoItemIOError,Microsoft.PowerShell.Commands.CopyItemCommand
+ PSComputerName : x.x.x.x
PS /home/username>
但同样的复制(使用 Copy-Item 命令)从 Windows 主机本身成功。
然后经过进一步调试,得知远程Ubuntu机器上的网络设备状态为Unavailable
PS /home/username> Invoke-Command -ComputerName x.x.x.x -ScriptBlock { net use } -Credential $cred -Authentication Negotiate
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
Unavailable Y: \\name\share Microsoft Windows Network
The command completed successfully.
PS /home/appadmin>
但是windows主机本身的网络设备状态显示OK
PS C:\Users\Administrator> net use
New connections will be remembered.
Status Local Remote Network
-------------------------------------------------------------------------------
OK Y: \\name\share Microsoft Windows Network
The command completed successfully.
PS C:\Users\Administrator>
我已经查看了网络设备的权限,没有问题。 而且这也不是双跳问题。
我应该怎么做才能使远程机器上的网络设备状态为 OK,以便我可以访问映射的网络设备 \name\share? 任何帮助表示赞赏
【问题讨论】:
标签: windows powershell powershell-remoting winrm mapped-drive