(GH-1563) Enhance the PSScript resources - #1657
Merged
Steve Lee (SteveL-MSFT) merged 8 commits intoAug 10, 2026
Merged
Conversation
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a lite review from Copilot
August 6, 2026 18:46
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a lite review from Copilot
August 6, 2026 19:45
Copilot started reviewing on behalf of
Mikey Lombardi (He/Him) (michaeltlombardi)
August 6, 2026 23:20
View session
Copilot started reviewing on behalf of
Mikey Lombardi (He/Him) (michaeltlombardi)
August 6, 2026 23:24
View session
Mikey Lombardi (He/Him) (michaeltlombardi)
force-pushed
the
gh-1563/main/psscript-enhance
branch
from
August 7, 2026 13:15
0979eca to
dd121ed
Compare
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a lite review from Copilot
August 7, 2026 13:15
Copilot started reviewing on behalf of
Mikey Lombardi (He/Him) (michaeltlombardi)
August 7, 2026 13:16
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Suppressed comments (5)
resources/PSScript/psscript.dsc.resource.json:163
- The schema embeds a canonical definition for
_inDesiredStatein$defs, but_inDesiredStatecurrently$refs the remote URL instead. This contradicts the PR description (embed + reference) and can introduce an unnecessary network dependency during schema resolution.
"_inDesiredState": {
"$ref": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/inDesiredState.json"
}
},
"$defs": {
"powershellScript": {
"writeOnly": true,
"type": "string",
"minLength": 1,
"contentMediaType": "text/vnd.microsoft.powershell"
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/inDesiredState.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
resources/PSScript/winpsscript.dsc.resource.json:162
- The schema embeds a canonical definition for
_inDesiredStatein$defs, but_inDesiredStatecurrently$refs the remote URL instead. This contradicts the PR description (embed + reference) and can introduce an unnecessary network dependency during schema resolution.
"_inDesiredState": {
"$ref": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/inDesiredState.json"
}
},
"$defs": {
"powershellScript": {
"writeOnly": true,
"type": "string",
"minLength": 1,
"contentMediaType": "text/vnd.microsoft.powershell"
},
"https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/resource/properties/inDesiredState.json": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
resources/PSScript/psscript.ps1:207
ConvertTo-Json -EnumsAsStringsis gated only by$PSVersionTable.PSVersion -ge 6.0, but the safer check is whether the runningConvertTo-Jsonactually supports the parameter. This avoids runtime failures on pwsh builds that don’t include-EnumsAsStrings(and naturally disables it on Windows PowerShell).
if ($PSVersionTable.PSVersion -ge [Version]'6.0') {
$toJsonParams['EnumsAsStrings'] = $true
}
resources/PSScript/psscript.dsc.resource.json:78
- This description says the empty-object return shape is only for operations with an undefined script, but
psscript.ps1now also emits an empty object when a script runs and produces no output. Updating the description avoids misleading schema docs.
This issue also appears on line 151 of the same file.
"description": "Defines the return data as an empty object for operations with an undefined script.",
"minProperties": 0,
"maxProperties": 0
},
resources/PSScript/winpsscript.dsc.resource.json:77
- This description says the empty-object return shape is only for operations with an undefined script, but
psscript.ps1now also emits an empty object when a script runs and produces no output. Updating the description avoids misleading schema docs.
This issue also appears on line 150 of the same file.
"description": "Defines the return data as an empty object for operations with an undefined script.",
"minProperties": 0,
"maxProperties": 0
},
Prior to this change, the PSScript resource manifests embedded a schema that minimally defined the `_inDesiredState` canonical property instead of referencing the canonical schema for that property. This change updates the embedded schemas to reference the canonical schema and adds the embedded schema by ID to the `$defs` keyword.
Prior to this change, the embedded schemas in the manifests for the
transitional PowerShell script resources defined the script properties
with a minimal schema allowing the value to be any string or null. They
didn't include any other keywords.
This change:
1. Defines a shared subschema for the script properties, which they now
reference instead of redefining the constraints for each property.
1. Removed `null` from the allowed types, since defining a script
property as `null` isn't valid but _not_ specifying the property at
all _is_ valid.
1. Added the `writeOnly` keyword to the script properties, since
they're only used for input and not output.
1. Added the `contentMediaType` keyword to the script properties to
clearly indicate---but not validate---that the value is expected to
be a PowerShell script.
1. Added the `minLength` keyword to the script properties to ensure that
an empty string isn't used as a script value.
1. Adds the `title` and `description` keywords to the script properties
to provide more context for each property in the schema.
Prior to this change, the `input` property for the PSScript resource schemas defined the valid types with two problems: 1. It allowed `null` as a valid type, which caused failures when the resource invoked the scripts. 1. It didn't allow non-integer numbers, erroneously preventing users from defining input values like `3.14`, even though `[3.14]` was accepted. This change: 1. Removes `null` from the valid types for `input`. 1. Adds `number` to the valid types for `input`, allowing non-integer numbers to be used as input values. 1. Adds the `title` and `description` keywords to the `input` property, providing better documentation for users.
Prior to this change, the embedded schemas for the PSScript resources didn't require any properties to be defined. For input, a user should always define at least one script property. For output, the resource should always return one of three value shapes: 1. For `test` operations, the resource should always define the `inDesiredState` property. 1. For implemented `get` and `set` operations, the resource should define the `output` property when the script emits any output to the success stream. 1. When `get` and `set` operations aren't implemented or don't emit any output, the resource should return an empty object. This change adds constraints to the embedded schemas with the `oneOf` keyword and nested `oneOf`/`anyOf` keywords to enforce these rules.
Prior to this change, the embedded schema for the PSScript resources didn't define the `title` or `description` keywords. This change: 1. Adds `title` and `description` keywords to the embedded schema for the PSScript resources to provide some documentation for them. 1. Defines the `$schema` keyword explicitly.
Prior to this change, the PSScript resources: 1. Always returned an array of output objects, even if there was only one object. 1. Didn't ensure that enums in script output were serialized as strings, causing enums to emit as integers, which is likely not what the user intended and makes review more difficult. This change: 1. Ensures that if a script returns a single object, it's serialized as that object instead of nested in an array. 1. Adds the `-EnumAsString` parameter to the `ConvertTo-Json` call for emitting script output when invoked through PowerShell to ensure that enums are serialized as strings. This enhancement doesn't affect Windows PowerShell, which doesn't support the `-EnumAsString` parameter. 1. Updates the tests to reflect the new behavior of returning a single object instead of an array. 1. Fixes the tests to use correct casing for the script properties, now that the schema validation checks for those properties.
Prior to this change, some tests were using invalid casing for the PSScript resource type, which didn't previously cause errors during the JSON Schema validation because the schema didn't forbid additional properties. The tests passed because PowerShell isn't case-sensitive, so was able to retrieve the properties even with incorrect casing. With the changes to the JSON schema _requiring_ one or more script properties, these tests began to fail because the invalidly-cased property names didn't satisfy the JSON Schema. This change corrects the casing in the test definitions to ensure both that the tests are correct and pass the schema validation.
Mikey Lombardi (He/Him) (michaeltlombardi)
force-pushed
the
gh-1563/main/psscript-enhance
branch
from
August 7, 2026 15:11
dd121ed to
d9831a1
Compare
Mikey Lombardi (He/Him) (michaeltlombardi)
marked this pull request as ready for review
August 7, 2026 15:42
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a review
from Steve Lee (SteveL-MSFT)
August 7, 2026 17:08
Steve Lee (SteveL-MSFT)
requested changes
Aug 8, 2026
Co-authored-by: Steve Lee <slee@microsoft.com>
Mikey Lombardi (He/Him) (michaeltlombardi)
requested a review
from Steve Lee (SteveL-MSFT)
August 10, 2026 15:48
Steve Lee (SteveL-MSFT)
approved these changes
Aug 10, 2026
Steve Lee (SteveL-MSFT)
added a commit
that referenced
this pull request
Aug 10, 2026
* feat: implement export filter functionality for resource exports (#1621) * feat: implement export filter functionality for resource exports * Remove comment * feat: implement export filter functionality for resource exports * Remove comment * Fix Copilot remarks * Wrong commit * Remove the wildcard support for resources * Fix Copilot remarks * Attempt to increase code coverage and fix test * Add additional test for coverage * Add test and fix dism_dsc * fix: correct code coverage calculation for uninstrumented files Files without LCOV data (e.g., platform-specific code behind #[cfg(windows)] when only Linux coverage is collected) were incorrectly counting ALL added lines as uncovered, including non-executable lines like comments and blanks. This caused coverage to drop significantly when Windows-only files were modified in a PR. Fix: skip files without LCOV data since coverage cannot be determined for uninstrumented code. Also handle the '\ No newline at end of file' diff marker which could cause off-by-one line number errors after deleted lines. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * Refactor work on services * Remove unused key * Revert change * Restore native resource filtering and add engine filtering fallback * Update resource definitions * Fix Copilot remark * remove directive * Change comment wording and update tests * Add crate * Revert change and fix test * Update resource manifest --------- Co-authored-by: Steve Lee <slee@microsoft.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> * (GH-1563) Enhance the PSScript resources (#1657) * (GH-1563) Canonicalize `_inDesiredState` for PSScript schema Prior to this change, the PSScript resource manifests embedded a schema that minimally defined the `_inDesiredState` canonical property instead of referencing the canonical schema for that property. This change updates the embedded schemas to reference the canonical schema and adds the embedded schema by ID to the `$defs` keyword. * (GH-1563) Canonicalize script properties for PSScript schemas Prior to this change, the embedded schemas in the manifests for the transitional PowerShell script resources defined the script properties with a minimal schema allowing the value to be any string or null. They didn't include any other keywords. This change: 1. Defines a shared subschema for the script properties, which they now reference instead of redefining the constraints for each property. 1. Removed `null` from the allowed types, since defining a script property as `null` isn't valid but _not_ specifying the property at all _is_ valid. 1. Added the `writeOnly` keyword to the script properties, since they're only used for input and not output. 1. Added the `contentMediaType` keyword to the script properties to clearly indicate---but not validate---that the value is expected to be a PowerShell script. 1. Added the `minLength` keyword to the script properties to ensure that an empty string isn't used as a script value. 1. Adds the `title` and `description` keywords to the script properties to provide more context for each property in the schema. * (GH-1563) Canonicalize `input` for PSScript resource schemas Prior to this change, the `input` property for the PSScript resource schemas defined the valid types with two problems: 1. It allowed `null` as a valid type, which caused failures when the resource invoked the scripts. 1. It didn't allow non-integer numbers, erroneously preventing users from defining input values like `3.14`, even though `[3.14]` was accepted. This change: 1. Removes `null` from the valid types for `input`. 1. Adds `number` to the valid types for `input`, allowing non-integer numbers to be used as input values. 1. Adds the `title` and `description` keywords to the `input` property, providing better documentation for users. * (GH-1563) Add constraints to PSScript resource schema Prior to this change, the embedded schemas for the PSScript resources didn't require any properties to be defined. For input, a user should always define at least one script property. For output, the resource should always return one of three value shapes: 1. For `test` operations, the resource should always define the `inDesiredState` property. 1. For implemented `get` and `set` operations, the resource should define the `output` property when the script emits any output to the success stream. 1. When `get` and `set` operations aren't implemented or don't emit any output, the resource should return an empty object. This change adds constraints to the embedded schemas with the `oneOf` keyword and nested `oneOf`/`anyOf` keywords to enforce these rules. * (GH-1563) Add docs keywords for PSScript resources Prior to this change, the embedded schema for the PSScript resources didn't define the `title` or `description` keywords. This change: 1. Adds `title` and `description` keywords to the embedded schema for the PSScript resources to provide some documentation for them. 1. Defines the `$schema` keyword explicitly. * (GH-1563) Canonicalize output for PSScript resources Prior to this change, the PSScript resources: 1. Always returned an array of output objects, even if there was only one object. 1. Didn't ensure that enums in script output were serialized as strings, causing enums to emit as integers, which is likely not what the user intended and makes review more difficult. This change: 1. Ensures that if a script returns a single object, it's serialized as that object instead of nested in an array. 1. Adds the `-EnumAsString` parameter to the `ConvertTo-Json` call for emitting script output when invoked through PowerShell to ensure that enums are serialized as strings. This enhancement doesn't affect Windows PowerShell, which doesn't support the `-EnumAsString` parameter. 1. Updates the tests to reflect the new behavior of returning a single object instead of an array. 1. Fixes the tests to use correct casing for the script properties, now that the schema validation checks for those properties. * (GH-1563) Fix tests using invalid casing for PSScript resource Prior to this change, some tests were using invalid casing for the PSScript resource type, which didn't previously cause errors during the JSON Schema validation because the schema didn't forbid additional properties. The tests passed because PowerShell isn't case-sensitive, so was able to retrieve the properties even with incorrect casing. With the changes to the JSON schema _requiring_ one or more script properties, these tests began to fail because the invalidly-cased property names didn't satisfy the JSON Schema. This change corrects the casing in the test definitions to ensure both that the tests are correct and pass the schema validation. * Apply suggestions from review Co-authored-by: Steve Lee <slee@microsoft.com> --------- Co-authored-by: Steve Lee <slee@microsoft.com> * Add JSON schema caching (#1637) * Add JSON schema caching * address copilot feedback * fix copilot feedback to not deserializing the json * rename function to be singular * make helpers scoped to crate * make cache crate only * fix: add support for preserving quoted group names in sshd_config (#1639) * fix: add support for preserving quoted group names in sshd_config * Update with remarks Tess --------- Co-authored-by: Gijs Reijn <26114636+Gijsreyn@users.noreply.github.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Co-authored-by: Mikey Lombardi (He/Him) <michael.t.lombardi@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
This change:
Canonicalizes the JSON Schema for the transitional PowerShell script resources by
titleanddescriptionkeywords for every property._inDesiredStateand referencing it instead of redefining it.contentMediaTypekeyword.output, or an object with_inDesiredState).inputand forbidding passingnullUpdates the emitted data for
output. Prior to this change, theoutputproperty was always an array. This change checks whether the resource emitted any output and:outputdefined as a scalar value when the script only emitted a single item.outputdefined as an array when the script emitted two or more items.PR Context
Addresses issues with the schema and implementation of the PSScript resources and fixes #1563.