Skip to content

Add explicit arg for enclosing resource path in quotes#1534

Merged
SteveL-MSFT merged 5 commits into
PowerShell:mainfrom
SteveL-MSFT:args-spaces
May 14, 2026
Merged

Add explicit arg for enclosing resource path in quotes#1534
SteveL-MSFT merged 5 commits into
PowerShell:mainfrom
SteveL-MSFT:args-spaces

Conversation

@SteveL-MSFT
Copy link
Copy Markdown
Member

PR Summary

If a PowerShell resource is in a folder that has spaces (like OneDrive), then the code flow:

sequenceDiagram
    dsc->>pwsh: pwsh -c powershell.resource.ps1 --resourcePath "c:\users\test\OneDrive - Test\resource.psm1"
    pwsh->>script: powershell.resource.ps1 --resourcePath c:\users\tests\OneDrive - Test\resource.psm1
Loading

dsc sends the path with quotes to pwsh, but when pwsh receives it, the correct value is sent, but the quotes have been stripped. So when pwsh sends the path to powershell.resource.ps1 the lack of quotes means it thinks they are positional parameters and fails.

The fix is to introduce a new optional property for:

{
  "resourcePathArg": "--foo",
  "includeQuotes": true
}

This will add additional quotes:

sequenceDiagram
    dsc->>pwsh: pwsh -c powershell.resource.ps1 --resourcePath "\"c:\users\test\OneDrive - Test\resource.psm1\""
    pwsh->>script: powershell.resource.ps1 --resourcePath "c:\users\tests\OneDrive - Test\resource.psm1"
Loading

So when the outer quotes are stripped, the inner quotes remain and get passed correctly to powershell.resource.ps1.

The test verifies that the correct escaped inner quotes are sent to the resource process.

Copilot AI review requested due to automatic review settings May 13, 2026 22:54
@SteveL-MSFT SteveL-MSFT added this to the 3.2-Consider milestone May 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an includeQuotes option for resource path arguments so adapter-invoked resources can preserve path quoting when routed through PowerShell command parsing.

Changes:

  • Extends manifest argument models with includeQuotes.
  • Applies quote-wrapping when processing resource path args.
  • Enables the option for the PowerShell adapter and adds a dsctest coverage scenario.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
lib/dsc-lib/src/dscresources/resource_manifest.rs Adds includeQuotes to resource path argument definitions.
lib/dsc-lib/src/dscresources/command_resource.rs Wraps resource paths in quotes when requested.
adapters/powershell/PowerShell_adapter.dsc.resource.json Enables quoted resource paths for PowerShell adapter operations.
tools/dsctest/dsctest.dsc.manifests.json Adds test manifest usage of includeQuotes.
dsc/tests/dsc_adapter.tests.ps1 Adds a Pester assertion for quoted resource path arguments.

Comment thread dsc/tests/dsc_adapter.tests.ps1 Outdated
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs Outdated
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs Outdated
Comment thread lib/dsc-lib/src/dscresources/resource_manifest.rs
Comment thread lib/dsc-lib/src/dscresources/resource_manifest.rs
Comment thread adapters/powershell/PowerShell_adapter.dsc.resource.json
Comment thread adapters/powershell/PowerShell_adapter.dsc.resource.json
Comment thread adapters/powershell/PowerShell_adapter.dsc.resource.json
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs Outdated
Comment thread lib/dsc-lib/src/dscresources/command_resource.rs Outdated
@SteveL-MSFT SteveL-MSFT requested a review from tgauth May 13, 2026 23:34
Comment thread adapters/powershell/Tests/PSAdapted.tests.ps1
Comment thread lib/dsc-lib/src/dscresources/resource_manifest.rs Outdated
Comment thread lib/dsc-lib/src/dscresources/resource_manifest.rs Outdated
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue May 14, 2026
Merged via the queue into PowerShell:main with commit d3f5eed May 14, 2026
36 of 37 checks passed
@SteveL-MSFT SteveL-MSFT deleted the args-spaces branch May 14, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants