-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Copy-Item from linux to windows with ToSessopn error #4952
Comments
My recommendation is to install OpenSSH on Windows and use SCP |
@dantraMSFT is working on getting new build of psrpclient library |
OpenSSH in the current case will suit me as the workaround decision, but with it a creation problem DataSources 64-bit. |
Hi All, Is this problem solved? I have the same problem:-( |
@couragecc would you mind trying this out with the latest RC Candidate or the 6.04 release Thanks. |
Here is current powershell version on my environment. Ubuntu: Name Value PSVersion 6.1.0-preview.2 Windows: Name Value PSVersion 5.1.14409.1005 |
I try installing the latest version powershell core 6.04 on Ubuntu as your suggestion, but still get the same problem on Windows remote powershell. PS C:\Users\Administrator.ICEBERG> Copy-Item "C:\cc\projects\workspace-trunk\cli\makefile.tsm" -Destination "/home/cc/project/" -ToSession $session -verbose
Copy-Item : Failed to copy file C:\cc\projects\workspace-trunk\cli\makefile.tsm to remote target destination.
Copy-Item : The runspace state is not valid for this operation.
Copy-Item : Cannot invoke the pipeline because the runspace is not in the Opened state. Current state of the runspace
|
@couragecc - the examples you are providing are the opposite of the title of the issue. The title indicates you're copying from Linux to Windows yet the example appears to be in the opposite direction. If you are going from Windows to Linux, I strongly recommend you use OpenSSH on both ends. It completely avoids having to use the OMI server on the target Linux machine and works quite well when using an RSA key. For example: $session = New-PSSession -HostName mylinuxsystem -UserName myuser -KeyFilePath ~\.ssh\myuser
Copy-Item -Path ~\myfile.txt -Destination /home/myuser -ToSession $session |
@dantraMSFT Thanks a lot! One more question: Shall I use OpenSSH for Copy files from Windows (Powershell 5) to linux (Powershell core 6.0) ?(This is my scenario) I saw some examples for both Linux and Windows side are Powershell core 6.0. |
@couragecc yes, recommendation is to use OpenSSH (scp) to copy files to and from Windows/Linux. This will work faster than trying to use copy-item (currently) due to base64 encoding the payload and wrapping it in XML for WSMan transport. |
@SteveL-MSFT @dantraMSFT , for the issue: Unable copy big file from Windows to Linux when we use
|
@aixiaozi the problem is that WSMan support on non-Windows hasn't been reliable. Plan is to move away from OMI client and invest in new PSRP/WSMan client library but that is a big work item and won't happen any time soon. You can also use tools like |
$Credential = Get-Credential -UserName example.com\username
$Session = New-PSSession -ComputerName destination.example.com -Credential $Credential -Authentication Negotiate
Copy-Item -Path patch.zip -Destination D:\Directory\patch.zip -ToSession $Session -Force
Remove-PSSession -Session $Session Still results in the following generic error:
Edit: And just as in the initial report, if the Edit 2: It does seem
Regardless of the above edit, it would seem preferable for us to use a single session for copying a file, then unpacking it and running a few local commands, therefore the questions still stand: |
4 years later the issue is still effective. `Copy-Item –Path testfile.txt –Destination 'C:\Installables' –ToSession (New-PSSession -Credential $cred -ComputerName $server -Authentication Negotiate) -Recurse -Force -Verbose Copy-Item –Path large-5.43.40.zip –Destination 'C:\Installables' –ToSession (New-PSSession -Credential $cred -ComputerName $server -Authentication Negotiate) -Recurse -Force -Verbose |
Hello Everybody, I was looking for the solution to this problem and I was able to find a website with the solution for this case. Check the link https://serverfault.com/questions/1020068/settings-to-upload-large-file-via-winrm-and-copy-item-powershell It describes that it is necessary to change the parameter MaxEnvelopeSizekb First check the current value with the command get-WSManInstance -ResourceURI winrm / config | Select-Object MaxEnvelopeSizekb Then change it to a higher value: Invoke-Command -Session $ s1 -ScriptBlock {set-WSManInstance -ResourceURI winrm / config -ValueSet @ {MaxEnvelopeSizekb = "256000"}} close #4952
|
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
1 similar comment
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you. |
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes. |
Steps to reproduce
Create 2 file:
dd if=/dev/zero of=/root/30KbFile bs=30K count=1
dd if=/dev/zero of=/root/1MbFile bs=30K count=1
Script for copying of files from linux in windows:
Run script
Expected behavior
Actual behavior
30KbFile file was copied, 1MbFile was not copied:
Environment data
The text was updated successfully, but these errors were encountered: