Skip to content

Commit 6585613

Browse files
committed
Add common issue from 965
1 parent eeee80f commit 6585613

File tree

1 file changed

+58
-1
lines changed

1 file changed

+58
-1
lines changed

docs/troubleshooting/known-issues.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This article lists known issues and troubleshooting guidance for Microsoft Desir
1515
The following table lists known issues with Microsoft DSC v3:
1616

1717
| Issue | Description | Status | Reported on |
18-
| :-------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------ | :-------- | :--------------------------------------------------- |
18+
|:---------------------------------------------------------------------------------------------------------------------:|:--------------------------------------------------------------------------------|:----------|:-----------------------------------------------------|
1919
| [Unable to parse content from `<manifestUrl>`](#unable-to-parse-content-from-manifesturl) | When authoring a resource manifest in VSCode, you may encounter parsing errors. | Confirmed | [#917](https://github.com/PowerShell/DSC/issues/917) |
2020
| [Resource not found when using Windows PowerShell adapter](#resource-not-found-when-using-windows-powershell-adapter) | A resource cannot be found when running DSC configuration using WinPS adapter. | Confirmed | [#765](https://github.com/PowerShell/DSC/issues/765) |
2121

@@ -83,6 +83,63 @@ included with Windows and requires separate installation.
8383
Install all DSC resources, whether script-based and binary resources, for all users
8484
("AllUsers" scope) to ensure they are available for the WinPS adapter.
8585

86+
## Validation errors when executing dsc.exe in Windows PowerShell sessions
87+
88+
When executing `dsc.exe` commands in Windows PowerShell sessions, you may encounter
89+
validation errors when using manually crafted JSON input or the `ConvertTo-Json` cmdlet
90+
with the `-Compress` parameter. This issue is related to how Windows PowerShell handles
91+
string encoding and JSON formatting.
92+
93+
### Prerequisites
94+
95+
- Windows PowerShell session
96+
- Direct execution of `dsc.exe` commands
97+
- Use of JSON input via `--input` parameter
98+
99+
### Problem details
100+
101+
When running `dsc.exe` commands in Windows PowerShell, validation errors may occur
102+
when passing JSON input to resources. This typically happens when using manually
103+
crafted JSON strings or when using PowerShell's `ConvertTo-Json` cmdlet with the `-Compress` parameter.
104+
105+
Commands that work correctly:
106+
107+
- `dsc resource get -r PSDesiredStateConfiguration/Service --input '{ "Name": "bits" }'`
108+
- `dsc resource get -r PSDesiredStateConfiguration/Service --input (@{Name = 'bits'} | ConvertTo-Json)`
109+
110+
Common error symptoms include:
111+
112+
- JSON parsing failures when using compressed JSON output
113+
- Property validation errors with valid JSON input
114+
- Cannot validate argument on parameter `<parameterName>`. The argument is null
115+
or empty, or an element of the argument collection contains a null value.
116+
117+
### Resolution steps
118+
119+
1. **Avoid the `-Compress` parameter**: Use `ConvertTo-Json` without the `-Compress` parameter
120+
for better compatibility.
121+
2. **Use properly formatted JSON**: Ensure JSON strings are properly quoted and formatted.
122+
3. **Test with uncompressed JSON**: When using PowerShell hashtables, convert to JSON
123+
without compression:
124+
125+
```powershell
126+
$input = @{Name = 'bits'} | ConvertTo-Json
127+
dsc resource get -r PSDesiredStateConfiguration/Service --input $input
128+
```
129+
130+
### Root causes
131+
132+
- Windows PowerShell's handling of compressed JSON may introduce formatting issues
133+
- String encoding differences between Windows PowerShell and `dsc.exe`
134+
- JSON parsing inconsistencies when using the `-Compress` parameter with `ConvertTo-Json`
135+
136+
### Recommendation
137+
138+
When executing `dsc.exe` commands in Windows PowerShell:
139+
140+
- Use `ConvertTo-Json` without the `-Compress` parameter
141+
- Consider using PowerShell 7+ for improved JSON handling compatibility
142+
86143
## See also
87144

88145
- [Microsoft Desired State Configuration overview](../overview.md)

0 commit comments

Comments
 (0)