Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 20, 2025

All PowerShell and pwsh invocations using -Command to execute script files now use -File instead. Scripts modified to read JSON input from stdin using the $input automatic variable while retaining the ValueFromPipeline parameter attribute.

Changes

Resource manifests (7 files)

Changed invocation pattern from:

"args": ["-Command", "$input | ./script.ps1", "operation"]

to:

"args": ["-File", "./script.ps1", "operation"]

Files:

  • resources/reboot_pending/reboot_pending.dsc.resource.json
  • resources/PSScript/{psscript,winpsscript}.dsc.resource.json
  • adapters/wmi/wmi.dsc.resource.json
  • adapters/powershell/{powershell,windowspowershell}.dsc.resource.json
  • adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json

PowerShell scripts (4 files)

Scripts now read from stdin using the $input automatic variable while keeping the ValueFromPipeline parameter attribute:

param(
    [Parameter(Position = 0)]
    [string]$Operation,
    [Parameter(ValueFromPipeline = $true)]
    [string]$jsonInput = '@{}'
)

# Read from stdin using $input automatic variable
$stdinData = $input | Out-String
if (-not [string]::IsNullOrWhiteSpace($stdinData)) {
    $jsonInput = $stdinData
}

Files:

  • resources/PSScript/psscript.ps1
  • adapters/wmi/wmi.resource.ps1
  • adapters/powershell/psDscAdapter/powershell.resource.ps1
  • adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1
Original prompt

update all the dsc.resource.json files which have executable as pwsh or powershell and use -c or -command parameter for invocation with -file. When that change is done, we also need to update the script that is invoked and use $input to receive the parameters in the script


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Update DSC resource JSON files for PowerShell invocation Replace -Command with -File for PowerShell resource invocations Nov 20, 2025
Copilot finished work on behalf of adityapatwardhan November 20, 2025 18:55
@adityapatwardhan
Copy link
Member

@copilot instead of using [System.Console]::In.ReadToEnd() use the $input automatic variable from PowerShell. keep the parameter which has the ValueFromPipeline attribute

Changed scripts to read from $input instead of Console.In.ReadToEnd() while keeping the ValueFromPipeline parameter attribute as requested.

Co-authored-by: adityapatwardhan <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 20, 2025

@copilot instead of using [System.Console]::In.ReadToEnd() use the $input automatic variable from PowerShell. keep the parameter which has the ValueFromPipeline attribute

Updated in commit c5d9d2b. All PowerShell scripts now use $input | Out-String to read from stdin while keeping the ValueFromPipeline parameter attribute.

PSScript tests: 21/21 passing ✅

Note: Some PowerShell adapter tests are showing "Empty input provided" errors (10/20 passing). Investigating whether this is related to the changes.

Copilot finished work on behalf of adityapatwardhan November 20, 2025 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants