Skip to content

ProgressView Minimal - Copy-Item error when copying to/from pssession #15251

@reaching-for-libra

Description

@reaching-for-libra

I've had some errors when copying a file from my local machine to another machine using the ToSession argument. I haven't had time to troubleshoot it, but I was able to force the same error when going the other direction, copying from the remote session to my local machine using the FromSession argument.

In the example below, if I shorten the directory name by one character, then the command succeeds.

Steps to reproduce

Copy-Item c:\temp\xxxxxxxxxx\web.config C:\tmp\xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\web.config -FromSession $session

Expected behavior

successful copy

Actual behavior

Exception             :
    Type       : System.ArgumentOutOfRangeException
    Message    : Length cannot be less than zero. (Parameter 'length')
    ParamName  : length
    TargetSite :
        Name          : Substring
        DeclaringType : string
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    StackTrace :
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Microsoft.PowerShell.ProgressNode.RenderAnsi(ArrayList strCollection, Int32 indentation, Int32 maxWidth)
   at Microsoft.PowerShell.ProgressNode.Render(ArrayList strCollection, Int32 indentation, Int32 maxWidth, PSHostRawUserInterface rawUI)
   at Microsoft.PowerShell.PendingProgress.RenderHelper(ArrayList strings, ArrayList nodes, Int32 indentation, Int32 maxWidth, PSHostRawUserInterface rawUI)
   at Microsoft.PowerShell.PendingProgress.Render(Int32 maxWidth, Int32 maxHeight, PSHostRawUserInterface rawUI)
   at Microsoft.PowerShell.ProgressPane.Show(PendingProgress pendingProgress)
   at Microsoft.PowerShell.ConsoleHostUserInterface.HandleIncomingProgressRecord(Int64 sourceId, ProgressRecord record)
   at Microsoft.PowerShell.ConsoleHostUserInterface.WriteProgress(Int64 sourceId, ProgressRecord record)
   at System.Management.Automation.Internal.Host.InternalHostUserInterface.WriteProgress(Int64 sourceId, ProgressRecord record)
   at System.Management.Automation.MshCommandRuntime.WriteProgress(Int64 sourceId, ProgressRecord progressRecord, Boolean overrideInquire)
   at System.Management.Automation.MshCommandRuntime.WriteProgress(ProgressRecord progressRecord, Boolean overrideInquire)
   at System.Management.Automation.MshCommandRuntime.WriteProgress(ProgressRecord progressRecord)
   at System.Management.Automation.Cmdlet.WriteProgress(ProgressRecord progressRecord)
   at System.Management.Automation.Provider.CmdletProvider.WriteProgress(ProgressRecord progressRecord)
   at Microsoft.PowerShell.Commands.FileSystemProvider.PerformCopyFileFromRemoteSession(String sourceFileFullName, FileInfo destinationFile, String destinationPath, Boolean force, PowerShell ps, Int64
fileSize, Boolean isAlternateDataStream, String streamName)
   at Microsoft.PowerShell.Commands.FileSystemProvider.CopyFileFromRemoteSession(String sourceFileName, String sourceFileFullName, String destinationPath, Boolean force, PowerShell ps, Int64 fileSize)
   at Microsoft.PowerShell.Commands.FileSystemProvider.CopyItemFromRemoteSession(String path, String destinationPath, Boolean recurse, Boolean force, PSSession fromSession)
   at Microsoft.PowerShell.Commands.FileSystemProvider.CopyItem(String path, String destinationPath, Boolean recurse)
   at System.Management.Automation.SessionStateInternal.CopyItem(CmdletProvider providerInstance, String path, String copyPath, Boolean recurse, CmdletProviderContext context)
    Source     : System.Private.CoreLib
    HResult    : -2146233086
CategoryInfo          : NotSpecified: (:) [Copy-Item], ArgumentOutOfRangeException
FullyQualifiedErrorId : System.ArgumentOutOfRangeException,Microsoft.PowerShell.Commands.CopyItemCommand

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.0-preview.5
PSEdition                      Core
GitCommitId                    7.2.0-preview.5
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

Labels

Issue-BugIssue has been identified as a bug in the productNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Interactive-Consolethe console experience

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions