-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
copy-item -tosession $a -path 'd:\a.txt' -Destination 'D:\nush' #problem ,both source and target are drive letter "D"
copy-item -tosession $a -path 'e:\a.txt' -Destination 'D:\nush' #normal
Cause of problem:
The drive letter of the source directory is the same as that of the target directory.
If the drive letter of the source directory difference target directory, normal.
Expected behavior
The copy succeeds without error messages and .Net exceptionsActual behavior
The copy succeeds with error messages and .Net exceptionsError details
get-error:
Exception :
Type : System.ComponentModel.Win32Exception
NativeErrorCode : 87
ErrorCode : -2147467259
TargetSite :
Name : GetStreams
DeclaringType : System.Management.Automation.Internal.AlternateDataStreamUtilities
MemberType : Method
Module : System.Management.Automation.dll
Message : 参数错误。
Source : System.Management.Automation
HResult : -2147467259
StackTrace :
at System.Management.Automation.Internal.AlternateDataStreamUtilities.GetStreams(String path)
at Microsoft.PowerShell.Commands.FileSystemProvider.PerformCopyFileToRemoteSession(FileInfo file, String destination
Path, PowerShell ps)
at Microsoft.PowerShell.Commands.FileSystemProvider.CopyFileInfoItem(FileInfo file, String destinationPath, Boolean
force, PowerShell ps)
at Microsoft.PowerShell.Commands.FileSystemProvider.CopyItemLocalOrToSession(String path, String destinationPath, Bo
olean recurse, Boolean Force, PowerShell ps)
at Microsoft.PowerShell.Commands.FileSystemProvider.CopyItem(String path, String destinationPath, Boolean recurse)
at System.Management.Automation.SessionStateInternal.CopyItem(CmdletProvider providerInstance, String path, String c
opyPath, Boolean recurse, CmdletProviderContext context)
CategoryInfo : NotSpecified: (:) [Copy-Item], Win32Exception
FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.CopyItemCommand
InvocationInfo :
MyCommand : Copy-Item
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 8
Line : copy-item -Path 'D:\h.txt' -Destination 'D:\j' -ToSession $a
PositionMessage : At line:1 char:1
+ copy-item -Path 'D:\h.txt' -Destination 'D:\j' -ToSession $a
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : copy-item
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1Environment data
all version
local pc:copy files source
powershell 5.1.18362.1801 on win10
powershell 7.2.0 on win10
target pc1:copy files target
powershell 5.1.19043 on win10
target pc2:copy files target
powershell 5.1 on win11Visuals
The [copyto node script] of KASINI3000 is a copy-item -tosession package based on PowerShell.
I always hear people report that copying files failed. To this end, I added try and re copy, but someone still reported this.
After analyzing the log, I found the problem.Looks like a bug.
Although the file was copied successfully, KASINI3000 can't stand this exception.
Because I wrote some code. If it is abnormal, script will copy it again and Exit 1.
Problem phenomenon:
- copy files succeeded.
- Report "parameter error"(参数错误)
- Throw an exception.
- only for -tosession.It has nothing to do with -fromsession