PowerShell / PowerShell/PowerShell

ParameterBindingArgumentTransformationException When using Copy-Item -ToSession

Open
#8,480 17 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Discussion KeepOpen Up-for-Grabs WG-Cmdlets WG-Remoting WG-Reviewed
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Steps to reproduce

Running this script.

$servers = "IP1", "IP2"

$sessions = New-PSSession -HostName $servers -UserName Administrator

Invoke-Command $sessions {
    Remove-Item -Force -Recurse "C:\EdgeDriver" -ErrorAction SilentlyContinue
    New-Item -ItemType Directory "C:\EdgeDriver" | Out-Null
}

foreach ($session in $sessions) {
    Copy-Item "C:/Users/redacted/Downloads/MicrosoftWebDriver.exe" "C:\EdgeDriver\MicrosoftWebDriver.exe" -ToSession $session
}

Get-PSSession | Remove-PSSession

The target servers are running:

  • Windows Server 2016 14393.2580
  • OpenSSH v7.7.2.0p1-Beta (sshd is running on desktop, these are automated testing nodes)
  • PowerShellCore 6.2.0-preview.1 (MSI package)

Expected behavior

File is copied with no errors.

Actual behavior

File is copied but the following error shows for every session.

Copy-Item : Cannot process argument transformation on parameter 'Encoding'. 'Byte' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
Parameter name: name
At C:\Users\redacted\Desktop\webdriver.ps1:9 char:5
+     Copy-Item "C:/Users/redacted/Downloads/MicrosoftWebDriver.exe" "C ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Write-Error], ParameterBindin...mationException
+ FullyQualifiedErrorId : System.Management.Automation.ParameterBindingArgumentTransformationException,PSCopyFileAlternateStreamToRemoteSession

Copy-Item : Failed to copy file C:\Users\redacted\Downloads\MicrosoftWebDriver.exe to remote target destination.
At C:\Users\redacted\Desktop\webdriver.ps1:9 char:5
+     Copy-Item "C:/Users/redacted/Downloads/MicrosoftWebDriver.exe" "C ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : WriteError: (C:\Users\redact...ftWebDriver.exe:String) [Copy-Item], IOException
+ FullyQualifiedErrorId : CopyError,Microsoft.PowerShell.Commands.CopyItemCommand

Environment data

Version on the workstation.

PSVersion                      6.2.0-preview.1
PSEdition                      Core
GitCommitId                    6.2.0-preview.1
OS                             Microsoft Windows 10.0.17134
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Copy-Item -ToSession reproduction and then trace the command's remote-copy and Encoding parameter-binding paths. The fix is complete when copying the executable to each PSSession produces no encoding or copy errors, with regression coverage added wherever the existing Copy-Item tests cover this behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.