Add PSGet to PSResourceGet migration tool#2015
Open
adityapatwardhan wants to merge 8 commits into
Open
Conversation
Adds a PowerShell-based migration tool that scans .ps1/.psm1/.psd1 files for PowerShellGet v2 cmdlet usage and converts them to PSResourceGet equivalents using AST-based parsing. Features: - 25 cmdlet mappings (Find-Module → Find-PSResource, etc.) - Parameter transformations (version ranges, renames, removals) - Dry-run report mode and in-place apply with backups - 30 Pester tests covering all conversion scenarios Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds ConvertTo-PSResourceGetString function and -InputScript parameter to the entry-point script, enabling direct string-to-string conversion without needing files on disk. Usage: .\ConvertTo-PSResourceGet.ps1 -InputScript 'Install-Module -Name Pester' 'Find-Module -Name Az' | .\ConvertTo-PSResourceGet.ps1 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Merge PSGetMigration.psm1/psd1 module into ConvertTo-PSResourceGet.ps1 as a self-contained script. All functions are defined inline and the main entry point is guarded so dot-sourcing for tests works correctly. Removes: PSGetMigration.psm1, PSGetMigration.psd1 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
adityapatwardhan
requested review from
SydneyhSmith,
alerickson,
anamnavi and
shammu1
as code owners
July 22, 2026 20:25
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds a new migration utility under tool/migration/ to convert PowerShellGet v2 cmdlet usage to PSResourceGet equivalents, including a Pester test suite and user documentation to support scripted migrations across .ps1/.psm1/.psd1 files.
Changes:
- Adds
ConvertTo-PSResourceGet.ps1, an AST-based scanner/converter with cmdlet + parameter mapping and optional in-place edits with backups. - Adds Pester coverage for command/parameter conversions, warnings, and apply/backup behavior.
- Adds a README documenting intended usage and conversion rules.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| tool/migration/ConvertTo-PSResourceGet.ps1 | Implements AST scanning + conversion logic, reporting, and apply-in-place behavior. |
| tool/migration/Tests/PSGetMigration.Tests.ps1 | Adds Pester tests validating conversion scenarios and apply/backup flows. |
| tool/migration/README.md | Documents mappings, parameter transforms, and intended usage patterns. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
adityapatwardhan
marked this pull request as draft
July 22, 2026 22:21
When -MinimumVersion or -MaximumVersion contains a variable reference (e.g. \), use double quotes for the version range string so the variable expands at runtime. Literal version strings continue to use single quotes. Before: -Version '(,\]' (broken - no expansion) After: -Version "(,\]" (correct - variable expands) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
- Replace Join-String (PS 7+ only) with -join operator for PS 5.1 compat - Add known switch parameter list to prevent consuming positional args after switches like -Force (e.g. 'Install-Module -Force Pester') - Fix README to document dot-sourcing instead of removed module manifest Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copy ConvertTo-PSResourceGet.ps1 to the 'migration' subdirectory of the module output during build. The existing signing step already signs all **\*.ps1 files under the output path, so the migration tool will be signed as part of the release pipeline automatically. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Adds a 'TestMigrationTool' job in the Test stage that runs the migration tool Pester tests on both PowerShell Core (pwsh) and Windows PowerShell. The job is independent of the module build since the migration tool is a standalone script. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Join-Path only accepts two path arguments in PS 5.1. Chain two Join-Path calls instead of passing three positional arguments. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
adityapatwardhan
marked this pull request as ready for review
July 23, 2026 17:50
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Member
Author
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
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
Adds a self-contained PowerShell script (
tool/migration/ConvertTo-PSResourceGet.ps1) that scans.ps1,.psm1, and.psd1files for PowerShellGet v2 cmdlet usage and converts them to their PSResourceGet equivalents.The tool uses PowerShell's AST parser to accurately identify PSGet v2 command invocations (avoiding false positives in comments or strings), then applies cmdlet name mappings, parameter renames, version range syntax transformations, and flags removed parameters with warnings.
Key capabilities:
Install-Module->Install-PSResource,Find-DscResource->Find-PSResource -Type DscResource)-MinimumVersion '1.0'->-Version '[1.0,)'), renames (-AllowPrerelease->-Prerelease,-NuGetApiKey->-ApiKey), and smart-Force->-Reinstallfor Install commands-Path) and direct string conversion (-InputScript)-Applyfor in-place edits with.bakbackupsPR Context
Users migrating from PowerShellGet v2 to PSResourceGet need to update cmdlet names and parameters across potentially many scripts. This tool automates that process, reducing manual effort and the risk of missed or incorrect conversions. It is placed under
tool/migration/as a standalone utility.PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:or[ WIP ]to the beginning of the title (theWIPbot will keep its status check atPendingwhile the prefix is present) and remove the prefix when the PR is ready.