From c0080732d9e3cc7289674d5f785af13fe3ad825b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:31:47 +0000 Subject: [PATCH 1/4] Initial plan From dabe5e48dae29c33076be29552c9efb4680f985a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:42:58 +0000 Subject: [PATCH 2/4] Update all PowerShell resource invocations from -Command to -File Co-authored-by: adityapatwardhan <12820925+adityapatwardhan@users.noreply.github.com> --- .../TestAdapter/testadapter.dsc.resource.json | 30 +++++++++++-------- .../TestAdapter/testadapter.resource.ps1 | 14 +++++++-- .../powershell/powershell.dsc.resource.json | 30 +++++++++++-------- .../psDscAdapter/powershell.resource.ps1 | 14 +++++++-- .../windowspowershell.dsc.resource.json | 30 +++++++++++-------- adapters/wmi/wmi.dsc.resource.json | 20 ++++++++----- adapters/wmi/wmi.resource.ps1 | 14 +++++++-- resources/PSScript/psscript.dsc.resource.json | 12 ++++---- resources/PSScript/psscript.ps1 | 7 +++-- .../PSScript/winpsscript.dsc.resource.json | 12 ++++---- .../reboot_pending.dsc.resource.json | 2 +- 11 files changed, 116 insertions(+), 69 deletions(-) diff --git a/adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json b/adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json index e05c85061..a3995edbe 100644 --- a/adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json +++ b/adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json @@ -14,8 +14,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "./testadapter.resource.ps1 List" + "-File", + "./testadapter.resource.ps1", + "List" ] }, "config": "full" @@ -26,8 +27,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "$Input | ./testadapter.resource.ps1 Get" + "-File", + "./testadapter.resource.ps1", + "Get" ], "input": "stdin" }, @@ -37,8 +39,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "$Input | ./testadapter.resource.ps1 Set" + "-File", + "./testadapter.resource.ps1", + "Set" ], "input": "stdin", "implementsPretest": true @@ -49,8 +52,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "$Input | ./testadapter.resource.ps1 Test" + "-File", + "./testadapter.resource.ps1", + "Test" ], "input": "stdin" }, @@ -60,8 +64,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "$Input | ./testadapter.resource.ps1 Export" + "-File", + "./testadapter.resource.ps1", + "Export" ], "input": "stdin" }, @@ -71,8 +76,9 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", - "$Input | ./testadapter.resource.ps1 Validate" + "-File", + "./testadapter.resource.ps1", + "Validate" ], "input": "stdin" }, diff --git a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 index 4dae5e0ac..7dea6a0db 100644 --- a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 +++ b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 @@ -4,11 +4,19 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Export, Validate.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Export', 'Validate')] - [string]$Operation, - [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] - [string]$jsonInput = '@{}' + [string]$Operation ) +# Read JSON input from stdin for operations that need it +$jsonInput = if ($Operation -ne 'List') { + $input | Out-String + if ([string]::IsNullOrWhiteSpace($jsonInput)) { + $jsonInput = '@{}' + } +} else { + '@{}' +} + function Write-DscTrace { param( [Parameter(Mandatory = $false)] diff --git a/adapters/powershell/powershell.dsc.resource.json b/adapters/powershell/powershell.dsc.resource.json index e481b0737..25fced4ed 100644 --- a/adapters/powershell/powershell.dsc.resource.json +++ b/adapters/powershell/powershell.dsc.resource.json @@ -16,8 +16,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "./psDscAdapter/powershell.resource.ps1 List" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "List" ] }, "config": "full" @@ -30,8 +31,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Get" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Get" ], "input": "stdin" }, @@ -43,8 +45,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Set" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Set" ], "input": "stdin", "implementsPretest": true @@ -57,8 +60,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Test" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Test" ], "input": "stdin", "return": "state" @@ -71,8 +75,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Export" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Export" ], "input": "stdin", "return": "state" @@ -85,8 +90,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Validate" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Validate" ], "input": "stdin" }, diff --git a/adapters/powershell/psDscAdapter/powershell.resource.ps1 b/adapters/powershell/psDscAdapter/powershell.resource.ps1 index fd4d116d6..03aa2500f 100644 --- a/adapters/powershell/psDscAdapter/powershell.resource.ps1 +++ b/adapters/powershell/psDscAdapter/powershell.resource.ps1 @@ -4,11 +4,19 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Export, Validate, ClearCache.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Export', 'Validate', 'ClearCache')] - [string]$Operation, - [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] - [string]$jsonInput = '@{}' + [string]$Operation ) +# Read JSON input from stdin for operations that need it +$jsonInput = if ($Operation -ne 'List' -and $Operation -ne 'ClearCache') { + $input | Out-String + if ([string]::IsNullOrWhiteSpace($jsonInput)) { + $jsonInput = '@{}' + } +} else { + '@{}' +} + function Write-DscTrace { param( [Parameter(Mandatory = $false)] diff --git a/adapters/powershell/windowspowershell.dsc.resource.json b/adapters/powershell/windowspowershell.dsc.resource.json index 297b44d05..751786b37 100644 --- a/adapters/powershell/windowspowershell.dsc.resource.json +++ b/adapters/powershell/windowspowershell.dsc.resource.json @@ -16,8 +16,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "./psDscAdapter/powershell.resource.ps1 List" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "List" ] }, "config": "full" @@ -30,8 +31,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Get" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Get" ], "input": "stdin" }, @@ -43,8 +45,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Set" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Set" ], "input": "stdin", "preTest": true @@ -57,8 +60,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Test" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Test" ], "input": "stdin", "return": "state" @@ -71,8 +75,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Export" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Export" ], "input": "stdin", "return": "state" @@ -85,8 +90,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./psDscAdapter/powershell.resource.ps1 Validate" + "-File", + "./psDscAdapter/powershell.resource.ps1", + "Validate" ] }, "exitCodes": { diff --git a/adapters/wmi/wmi.dsc.resource.json b/adapters/wmi/wmi.dsc.resource.json index d37ca2dd8..b6536b709 100644 --- a/adapters/wmi/wmi.dsc.resource.json +++ b/adapters/wmi/wmi.dsc.resource.json @@ -16,8 +16,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "./wmi.resource.ps1 List" + "-File", + "./wmi.resource.ps1", + "List" ] }, "config": "full" @@ -30,8 +31,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./wmi.resource.ps1 Get" + "-File", + "./wmi.resource.ps1", + "Get" ], "input": "stdin" }, @@ -43,8 +45,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./wmi.resource.ps1 Set" + "-File", + "./wmi.resource.ps1", + "Set" ], "input": "stdin", "implementsPretest": false @@ -57,8 +60,9 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$Input | ./wmi.resource.ps1 Validate" + "-File", + "./wmi.resource.ps1", + "Validate" ] }, "exitCodes": { diff --git a/adapters/wmi/wmi.resource.ps1 b/adapters/wmi/wmi.resource.ps1 index 102db4d34..33597fe13 100644 --- a/adapters/wmi/wmi.resource.ps1 +++ b/adapters/wmi/wmi.resource.ps1 @@ -4,11 +4,19 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Validate.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Validate')] - [string]$Operation, - [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] - [string]$jsonInput = '@{}' + [string]$Operation ) +# Read JSON input from stdin for operations that need it +$jsonInput = if ($Operation -ne 'List') { + $input | Out-String + if ([string]::IsNullOrWhiteSpace($jsonInput)) { + $jsonInput = '@{}' + } +} else { + '@{}' +} + # Import private functions $wmiAdapter = Import-Module "$PSScriptRoot\wmiAdapter.psm1" -Force -PassThru diff --git a/resources/PSScript/psscript.dsc.resource.json b/resources/PSScript/psscript.dsc.resource.json index fda07988d..b754c7853 100644 --- a/resources/PSScript/psscript.dsc.resource.json +++ b/resources/PSScript/psscript.dsc.resource.json @@ -11,8 +11,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "get" ], "input": "stdin" @@ -25,8 +25,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "set" ], "implementsPretest": true, @@ -41,8 +41,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "test" ], "input": "stdin", diff --git a/resources/PSScript/psscript.ps1 b/resources/PSScript/psscript.ps1 index 2b395dce1..9bdada6a5 100644 --- a/resources/PSScript/psscript.ps1 +++ b/resources/PSScript/psscript.ps1 @@ -4,11 +4,12 @@ param( [Parameter(Mandatory = $true, Position = 0)] [ValidateSet('Get', 'Set', 'Test')] - [string]$Operation, - [Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)] - [string]$jsonInput + [string]$Operation ) +# Read JSON input from stdin +$jsonInput = $input | Out-String + function Write-DscTrace { param( [Parameter(Mandatory = $true)] diff --git a/resources/PSScript/winpsscript.dsc.resource.json b/resources/PSScript/winpsscript.dsc.resource.json index 25b73b81c..e45fa5568 100644 --- a/resources/PSScript/winpsscript.dsc.resource.json +++ b/resources/PSScript/winpsscript.dsc.resource.json @@ -11,8 +11,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "get" ], "input": "stdin" @@ -25,8 +25,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "set" ], "implementsPretest": true, @@ -41,8 +41,8 @@ "-NoProfile", "-ExecutionPolicy", "Bypass", - "-Command", - "$input | ./psscript.ps1", + "-File", + "./psscript.ps1", "test" ], "input": "stdin", diff --git a/resources/reboot_pending/reboot_pending.dsc.resource.json b/resources/reboot_pending/reboot_pending.dsc.resource.json index 590d9dc95..5f6606a40 100644 --- a/resources/reboot_pending/reboot_pending.dsc.resource.json +++ b/resources/reboot_pending/reboot_pending.dsc.resource.json @@ -9,7 +9,7 @@ "-NoLogo", "-NonInteractive", "-NoProfile", - "-Command", + "-File", "reboot_pending.resource.ps1" ] }, From 28c7fb04206e64bbb92b8776ef2045c465d4e7df Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 18:45:52 +0000 Subject: [PATCH 3/4] Fix stdin reading in PowerShell scripts to use Console.In.ReadToEnd Co-authored-by: adityapatwardhan <12820925+adityapatwardhan@users.noreply.github.com> --- adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 | 2 +- adapters/powershell/psDscAdapter/powershell.resource.ps1 | 2 +- adapters/wmi/wmi.resource.ps1 | 2 +- resources/PSScript/psscript.ps1 | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 index 7dea6a0db..7ef911350 100644 --- a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 +++ b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 @@ -9,7 +9,7 @@ param( # Read JSON input from stdin for operations that need it $jsonInput = if ($Operation -ne 'List') { - $input | Out-String + [System.Console]::In.ReadToEnd() if ([string]::IsNullOrWhiteSpace($jsonInput)) { $jsonInput = '@{}' } diff --git a/adapters/powershell/psDscAdapter/powershell.resource.ps1 b/adapters/powershell/psDscAdapter/powershell.resource.ps1 index 03aa2500f..ab9be937a 100644 --- a/adapters/powershell/psDscAdapter/powershell.resource.ps1 +++ b/adapters/powershell/psDscAdapter/powershell.resource.ps1 @@ -9,7 +9,7 @@ param( # Read JSON input from stdin for operations that need it $jsonInput = if ($Operation -ne 'List' -and $Operation -ne 'ClearCache') { - $input | Out-String + [System.Console]::In.ReadToEnd() if ([string]::IsNullOrWhiteSpace($jsonInput)) { $jsonInput = '@{}' } diff --git a/adapters/wmi/wmi.resource.ps1 b/adapters/wmi/wmi.resource.ps1 index 33597fe13..6e196a202 100644 --- a/adapters/wmi/wmi.resource.ps1 +++ b/adapters/wmi/wmi.resource.ps1 @@ -9,7 +9,7 @@ param( # Read JSON input from stdin for operations that need it $jsonInput = if ($Operation -ne 'List') { - $input | Out-String + [System.Console]::In.ReadToEnd() if ([string]::IsNullOrWhiteSpace($jsonInput)) { $jsonInput = '@{}' } diff --git a/resources/PSScript/psscript.ps1 b/resources/PSScript/psscript.ps1 index 9bdada6a5..d6aa5e7f5 100644 --- a/resources/PSScript/psscript.ps1 +++ b/resources/PSScript/psscript.ps1 @@ -8,7 +8,7 @@ param( ) # Read JSON input from stdin -$jsonInput = $input | Out-String +$jsonInput = [System.Console]::In.ReadToEnd() function Write-DscTrace { param( From c5d9d2b68656c4728f54e84179ce1f5acacb2d92 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 20 Nov 2025 19:09:40 +0000 Subject: [PATCH 4/4] Use $input automatic variable with ValueFromPipeline parameter Changed scripts to read from $input instead of Console.In.ReadToEnd() while keeping the ValueFromPipeline parameter attribute as requested. Co-authored-by: adityapatwardhan <12820925+adityapatwardhan@users.noreply.github.com> --- .../Tests/TestAdapter/testadapter.resource.ps1 | 16 ++++++++-------- .../psDscAdapter/powershell.resource.ps1 | 16 ++++++++-------- adapters/wmi/wmi.resource.ps1 | 16 ++++++++-------- resources/PSScript/psscript.ps1 | 11 ++++++++--- 4 files changed, 32 insertions(+), 27 deletions(-) diff --git a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 index 7ef911350..440911788 100644 --- a/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 +++ b/adapters/powershell/Tests/TestAdapter/testadapter.resource.ps1 @@ -4,17 +4,17 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Export, Validate.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Export', 'Validate')] - [string]$Operation + [string]$Operation, + [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] + [string]$jsonInput = '@{}' ) -# Read JSON input from stdin for operations that need it -$jsonInput = if ($Operation -ne 'List') { - [System.Console]::In.ReadToEnd() - if ([string]::IsNullOrWhiteSpace($jsonInput)) { - $jsonInput = '@{}' +# Read JSON input from stdin using $input automatic variable for operations that need it +if ($Operation -ne 'List') { + $stdinData = $input | Out-String + if (-not [string]::IsNullOrWhiteSpace($stdinData)) { + $jsonInput = $stdinData } -} else { - '@{}' } function Write-DscTrace { diff --git a/adapters/powershell/psDscAdapter/powershell.resource.ps1 b/adapters/powershell/psDscAdapter/powershell.resource.ps1 index ab9be937a..f34827394 100644 --- a/adapters/powershell/psDscAdapter/powershell.resource.ps1 +++ b/adapters/powershell/psDscAdapter/powershell.resource.ps1 @@ -4,17 +4,17 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Export, Validate, ClearCache.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Export', 'Validate', 'ClearCache')] - [string]$Operation + [string]$Operation, + [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] + [string]$jsonInput = '@{}' ) -# Read JSON input from stdin for operations that need it -$jsonInput = if ($Operation -ne 'List' -and $Operation -ne 'ClearCache') { - [System.Console]::In.ReadToEnd() - if ([string]::IsNullOrWhiteSpace($jsonInput)) { - $jsonInput = '@{}' +# Read JSON input from stdin using $input automatic variable for operations that need it +if ($Operation -ne 'List' -and $Operation -ne 'ClearCache') { + $stdinData = $input | Out-String + if (-not [string]::IsNullOrWhiteSpace($stdinData)) { + $jsonInput = $stdinData } -} else { - '@{}' } function Write-DscTrace { diff --git a/adapters/wmi/wmi.resource.ps1 b/adapters/wmi/wmi.resource.ps1 index 6e196a202..27a7001c4 100644 --- a/adapters/wmi/wmi.resource.ps1 +++ b/adapters/wmi/wmi.resource.ps1 @@ -4,17 +4,17 @@ param( [Parameter(Mandatory = $true, Position = 0, HelpMessage = 'Operation to perform. Choose from List, Get, Set, Test, Validate.')] [ValidateSet('List', 'Get', 'Set', 'Test', 'Validate')] - [string]$Operation + [string]$Operation, + [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true, HelpMessage = 'Configuration or resource input in JSON format.')] + [string]$jsonInput = '@{}' ) -# Read JSON input from stdin for operations that need it -$jsonInput = if ($Operation -ne 'List') { - [System.Console]::In.ReadToEnd() - if ([string]::IsNullOrWhiteSpace($jsonInput)) { - $jsonInput = '@{}' +# Read JSON input from stdin using $input automatic variable for operations that need it +if ($Operation -ne 'List') { + $stdinData = $input | Out-String + if (-not [string]::IsNullOrWhiteSpace($stdinData)) { + $jsonInput = $stdinData } -} else { - '@{}' } # Import private functions diff --git a/resources/PSScript/psscript.ps1 b/resources/PSScript/psscript.ps1 index d6aa5e7f5..230e37fd4 100644 --- a/resources/PSScript/psscript.ps1 +++ b/resources/PSScript/psscript.ps1 @@ -4,11 +4,16 @@ param( [Parameter(Mandatory = $true, Position = 0)] [ValidateSet('Get', 'Set', 'Test')] - [string]$Operation + [string]$Operation, + [Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true)] + [string]$jsonInput = '' ) -# Read JSON input from stdin -$jsonInput = [System.Console]::In.ReadToEnd() +# Read JSON input from stdin using $input automatic variable +$stdinData = $input | Out-String +if (-not [string]::IsNullOrWhiteSpace($stdinData)) { + $jsonInput = $stdinData +} function Write-DscTrace { param(