Forum Discussion
Paige__Tanner
Jan 17, 2024Brass Contributor
Incomplete files copied to a remote host with Copy-Item
Hello! I tried to copy a file (of about 1 GB) from host1 to host2 through PowerShell's Copy-Item. host1 runs PowerShell 7.4.0 and Windows 11, host2 runs Windows 10 with its default version of Po...
LainRobertson
Jan 18, 2024Silver Contributor
Hi, Paige.
I'm honestly not sure what the issue might be, as since I cannot reproduce the issue, it leaves guessing as the only option I have.
So, you have two hosts that you've already tested with, which are:
Label | Platform | PowerShell |
Host 1 | Windows 11 | Has PowerShell 7.4 |
Host 2 | Windows 10 | Only has Windows PowerShell |
If would be interesting to introduce a third host:
Label | Platform | PowerShell |
Host 3 | Windows 10 or 11 | Only has Windows PowerShell |
And then try the copy from Host 3 back to the original Host 2.
I have no idea if this would produce a different result but it could indicate what to focus on, insofar as:
- If the whole files copies, then I'd focus on Host 1;
- If the whole file only copies that same 3 MB then I'd focus on Host 2.
It's really just structured guesswork but if you have a third machine, it'd be quick and worth doing.
I also have a funny feeling this might come down to which options are chosen during the PowerShell 7.4 setup, too, as I seem to recall there's some options in there around defaults (which I always unselect), but that may have exactly nothing to do with this issue. It's just an isolated thought that if I were trying to diagnose this, I might come back to after running the Host 3 scenario above.
I'm hoping someone else might have seen this before and can provide some detailed insight, as guessing doesn't inspire much confidence.
Cheers,
Lain
Paige__Tanner
Jan 18, 2024Brass Contributor
Your table is correct: it perfectly depicts the scenario.
Unfortunately I don't have a host3 available, so my tests have only been between host1 and host2.
I installed in host2 PowerShell 7.4.1 (and during the installation no options were asked to choose, so maybe the PowerShell 7.4 setup you are mentioning can be done in a separate moment) and I enabled PSRemoting also there.
Then, I made several tests between host1 and host2 (trasferring not only files from host1 to host2 but also vice-versa), specifying either
$test_transfer = New-PSSession host2 -Credential host2-user -ConfigurationName microsoft.powershell
or
$test_transfer = New-PSSession host2 -Credential host2-user -ConfigurationName powershell.7.4.1
so selecting which PowerShell must be used in the destination host. I didn't cover all the possible cases, but many.
This way, all the file transfers were successful, except for one case: when running PowerShell 7.4 in host1 and selecting "-ConfigurationName microsoft.powershell", so using Windows PowerShell 5.1 in host2 as receiving program. In this case, even if the transfer of a huge file (hundreds of MBs) was completed, only a 3 MB file remained in host2, unreadable.
As you previously guessed, probably this was due to a compatibility issue between PowerShell 7.4 and Windows PowerShell 5.1, when the former is used as sender and the latter as receiver (vice-versa was instead ok, at least during my tests). So I suggest to use PowerShell 7.4 in both.