Назад | Перейти на главную страницу

Копирование элемента PowerShell из удаленного сеанса

Я могу передавать файлы в удаленный сеанс, однако мне не удалось получить файлы из него. Удаленная система - это компьютер с Windows 7 с PowerShell v2.0 из Windows 10 Enterprise.

Первоначально я пытался получить папку, но теперь я решил попробовать что-то более простое, простой текстовый файл, пока у меня это не заработает.

Я считаю, что первая ошибка - это ошибка, и файл все равно следует скопировать. Когда я передавал файлы на удаленный компьютер, он выдавал ту же ошибку, но файл все еще передавался.

командлет: 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

Буду очень признателен за помощь, спасибо!