我能够将文件传输到远程会话,但是我无法从中检索文件。远程系统是一台装有 PowerShell v2.0 的 Windows 7 计算机,来自 Windows 10 Enterprise。
我最初尝试检索一个文件夹,但现在我决定尝试一些更简单的东西,一个简单的文本文件,直到我让它工作为止。
我认为第一个错误是一个 bug,文件仍然应该被复制。当我将文件传输到远程计算机时,它给出了相同的错误,但文件仍然被传输了。
命令:Copy-Item "C:\Users\Public\Test.txt" -Destination "C:\" -FromSession $session
错误:
Copy-Item : Unable to index into an object of type System.IO.FileInfo.
At line:1 char:1
+ Copy-Item "C:\Users\Public\Test.txt" -Destination "C:\" -FromSession ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (0:Int32) [Copy-Item], RuntimeException
+ FullyQualifiedErrorId : CannotIndex
Copy-Item : Parameter attributes need to be a constant or a script block.
At line:1 char:1
+ Copy-Item "C:\Users\Public\Test.txt" -Destination "C:\" -FromSession ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Management.Automation.PowerShell:PowerShell) [Copy-Item], RemoteException
+ FullyQualifiedErrorId : CopyFileRemoteExecutionError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : The term 'PSCopyFromSessionHelper' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling
of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Copy-Item "C:\Users\Public\Test.txt" -Destination "C:\" -FromSession ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Management.Automation.PowerShell:PowerShell) [Copy-Item], RemoteException
+ FullyQualifiedErrorId : CopyFileRemoteExecutionError,Microsoft.PowerShell.Commands.CopyItemCommand
Copy-Item : Failed to read remote file 'C:\Users\Public\Test.txt'.
At line:1 char:1
+ Copy-Item "C:\Users\Public\Test.txt" -Destination "C:\" -FromSession ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (C:\Users\Public\Test.txt:String) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyItemRemotelyFailedToReadFile,Microsoft.PowerShell.Commands.CopyItemCommand
我将非常感激您的帮助,谢谢!