Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 18 additions & 12 deletions adapters/powershell/Tests/TestAdapter/testadapter.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"./testadapter.resource.ps1 List"
"-File",
"./testadapter.resource.ps1",
"List"
]
},
"config": "full"
Expand All @@ -26,8 +27,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"$Input | ./testadapter.resource.ps1 Get"
"-File",
"./testadapter.resource.ps1",
"Get"
],
"input": "stdin"
},
Expand All @@ -37,8 +39,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"$Input | ./testadapter.resource.ps1 Set"
"-File",
"./testadapter.resource.ps1",
"Set"
],
"input": "stdin",
"implementsPretest": true
Expand All @@ -49,8 +52,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"$Input | ./testadapter.resource.ps1 Test"
"-File",
"./testadapter.resource.ps1",
"Test"
],
"input": "stdin"
},
Expand All @@ -60,8 +64,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"$Input | ./testadapter.resource.ps1 Export"
"-File",
"./testadapter.resource.ps1",
"Export"
],
"input": "stdin"
},
Expand All @@ -71,8 +76,9 @@
"-NoLogo",
"-NonInteractive",
"-NoProfile",
"-Command",
"$Input | ./testadapter.resource.ps1 Validate"
"-File",
"./testadapter.resource.ps1",
"Validate"
],
"input": "stdin"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ param(
[string]$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
}
}

function Write-DscTrace {
param(
[Parameter(Mandatory = $false)]
Expand Down
30 changes: 18 additions & 12 deletions adapters/powershell/powershell.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"./psDscAdapter/powershell.resource.ps1 List"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"List"
]
},
"config": "full"
Expand All @@ -30,8 +31,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Get"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Get"
],
"input": "stdin"
},
Expand All @@ -43,8 +45,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Set"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Set"
],
"input": "stdin",
"implementsPretest": true
Expand All @@ -57,8 +60,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Test"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Test"
],
"input": "stdin",
"return": "state"
Expand All @@ -71,8 +75,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Export"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Export"
],
"input": "stdin",
"return": "state"
Expand All @@ -85,8 +90,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Validate"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Validate"
],
"input": "stdin"
},
Expand Down
8 changes: 8 additions & 0 deletions adapters/powershell/psDscAdapter/powershell.resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ param(
[string]$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
}
}

function Write-DscTrace {
param(
[Parameter(Mandatory = $false)]
Expand Down
30 changes: 18 additions & 12 deletions adapters/powershell/windowspowershell.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"./psDscAdapter/powershell.resource.ps1 List"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"List"
]
},
"config": "full"
Expand All @@ -30,8 +31,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Get"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Get"
],
"input": "stdin"
},
Expand All @@ -43,8 +45,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Set"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Set"
],
"input": "stdin",
"preTest": true
Expand All @@ -57,8 +60,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Test"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Test"
],
"input": "stdin",
"return": "state"
Expand All @@ -71,8 +75,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Export"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Export"
],
"input": "stdin",
"return": "state"
Expand All @@ -85,8 +90,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./psDscAdapter/powershell.resource.ps1 Validate"
"-File",
"./psDscAdapter/powershell.resource.ps1",
"Validate"
]
},
"exitCodes": {
Expand Down
20 changes: 12 additions & 8 deletions adapters/wmi/wmi.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"./wmi.resource.ps1 List"
"-File",
"./wmi.resource.ps1",
"List"
]
},
"config": "full"
Expand All @@ -30,8 +31,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./wmi.resource.ps1 Get"
"-File",
"./wmi.resource.ps1",
"Get"
],
"input": "stdin"
},
Expand All @@ -43,8 +45,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./wmi.resource.ps1 Set"
"-File",
"./wmi.resource.ps1",
"Set"
],
"input": "stdin",
"implementsPretest": false
Expand All @@ -57,8 +60,9 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$Input | ./wmi.resource.ps1 Validate"
"-File",
"./wmi.resource.ps1",
"Validate"
]
},
"exitCodes": {
Expand Down
8 changes: 8 additions & 0 deletions adapters/wmi/wmi.resource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ param(
[string]$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
}
}

# Import private functions
$wmiAdapter = Import-Module "$PSScriptRoot\wmiAdapter.psm1" -Force -PassThru

Expand Down
12 changes: 6 additions & 6 deletions resources/PSScript/psscript.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"get"
],
"input": "stdin"
Expand All @@ -25,8 +25,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"set"
],
"implementsPretest": true,
Expand All @@ -41,8 +41,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"test"
],
"input": "stdin",
Expand Down
10 changes: 8 additions & 2 deletions resources/PSScript/psscript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ param(
[Parameter(Mandatory = $true, Position = 0)]
[ValidateSet('Get', 'Set', 'Test')]
[string]$Operation,
[Parameter(Mandatory = $true, Position = 1, ValueFromPipeline = $true)]
[string]$jsonInput
[Parameter(Mandatory = $false, Position = 1, ValueFromPipeline = $true)]
[string]$jsonInput = ''
)

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

function Write-DscTrace {
param(
[Parameter(Mandatory = $true)]
Expand Down
12 changes: 6 additions & 6 deletions resources/PSScript/winpsscript.dsc.resource.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"get"
],
"input": "stdin"
Expand All @@ -25,8 +25,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"set"
],
"implementsPretest": true,
Expand All @@ -41,8 +41,8 @@
"-NoProfile",
"-ExecutionPolicy",
"Bypass",
"-Command",
"$input | ./psscript.ps1",
"-File",
"./psscript.ps1",
"test"
],
"input": "stdin",
Expand Down
Loading
Loading