Replace -Command with -File for PowerShell resource invocations
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.jsonresources/PSScript/{psscript,winpsscript}.dsc.resource.jsonadapters/wmi/wmi.dsc.resource.jsonadapters/powershell/{powershell,windowspowershell}.dsc.resource.jsonadapters/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.ps1adapters/wmi/wmi.resource.ps1adapters/powershell/psDscAdapter/powershell.resource.ps1adapters/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 instead of using [System.Console]::In.ReadToEnd() use the $input automatic variable from PowerShell. keep the parameter which has the ValueFromPipeline attribute
@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.