Fix the scripts used for Copy-Item -FromSessoin/-ToSession scenarios and also enable tests - #27773
Open
Dongbo Wang (daxian-dbw) wants to merge 3 commits into
Open
Fix the scripts used for Copy-Item -FromSessoin/-ToSession scenarios and also enable tests #27773Dongbo Wang (daxian-dbw) wants to merge 3 commits into
Copy-Item -FromSessoin/-ToSession scenarios and also enable tests #27773Dongbo Wang (daxian-dbw) wants to merge 3 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copy-Item Copy-Item -FromSessoin/-ToSession scenarios and also enable tests
Dongbo Wang (daxian-dbw)
marked this pull request as ready for review
August 7, 2026 17:20
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the PowerShell-side scripts used by Copy-Item -FromSession/-ToSession (including alternate data stream copy) and PSEdit so they read/write raw bytes correctly in PowerShell 7+ by using -AsByteStream (while retaining -Encoding Byte for Windows PowerShell / Desktop). It also attempts to re-enable previously-disabled remoting tests for Copy-Item on Windows via the HelpersRemoting module.
Changes:
- Update remote copy helper scripts to use
Get-Content/Add-Content -AsByteStreamwhen running onPSEdition = Core. - Update the
PSEditsupport script to useGet-Content -AsByteStreamonPSEdition = Core. - Rework
Copy-Itemremoting tests to useNew-RemoteSessionand add Windows/admin gating tags.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| test/powershell/Modules/Microsoft.PowerShell.Management/Copy-Item.Tests.ps1 | Re-enables/adjusts remoting tests using HelpersRemoting and adds platform/admin gating. |
| src/System.Management.Automation/namespaces/FileSystemProvider.cs | Fixes alternate stream remote copy scripts to use -AsByteStream on PowerShell Core. |
| src/System.Management.Automation/engine/hostifaces/HostUtilities.cs | Fixes PSEdit remote file-open script to use -AsByteStream on PowerShell Core. |
Ilya (iSazonov)
approved these changes
Aug 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Copy-Item -FromSessoin/-ToSessionandPSEdit. They use-Encoding Byte, which only works in PS5.1. In PS 7+, we need to use-AsByteStreaminstead. So, those scenarios (copy alternate data stream to/from remote PS 7 session and edit file from a remote PS 7 session) have been broken for a long time.Copy-Itemhave always been disabled. This PR re-enables those tests for Windows (theHelperRemotingmodule only works on Windows).PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header