Skip to content

Commit 464eee6

Browse files
committed
Add known issue with Windows PowerShell adapter
1 parent ec8fd50 commit 464eee6

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

docs/troubleshooting/known-issues.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,39 @@ When executing `dsc.exe` commands in Windows PowerShell:
146146
- Use `ConvertTo-Json` without the `-Compress` parameter.
147147
- Consider using PowerShell 7+ for improved JSON handling compatibility.
148148

149+
## Zero results when listing resources with Windows PowerShell adapter
150+
151+
When running `dsc resource list --adapter Microsoft.Windows/WindowsPowerShell`, you
152+
may see zero resources returned. In trace or debug logs, an error like the following can
153+
appear: "Cannot bind argument to parameter 'Path' because it is an empty string."
154+
155+
### Problem details
156+
157+
This issue occurs when the `PSModulePath` environment variable ends with a trailing path
158+
separator (`;`). The PSDesiredStateConfiguration v1.1 module doesn't handle the empty path
159+
segment and throws an error while enumerating modules, which results in zero resources being
160+
listed by `dsc resource list`.
161+
162+
### Resolution steps
163+
164+
Remove any trailing path separators from `PSModulePath` so there are no empty entries:
165+
166+
```powershell
167+
# Show current PSModulePath entries (note any empty items at the end)
168+
$env:PSModulePath -split ';'
169+
170+
# Remove empty entries and rejoin (session only)
171+
$env:PSModulePath = ($env:PSModulePath -split ';' | Where-Object { $_ -ne '' }) -join ';'
172+
173+
# Re-run the listing
174+
dsc resource list --adapter Microsoft.Windows/WindowsPowerShell
175+
```
176+
177+
### Recommendation
178+
179+
Avoid trailing semicolons in `PSModulePath` variable. Ensure all path segments are non-empty
180+
to prevent PSDSC 1.1 from encountering empty paths during module discovery.
181+
149182
## See also
150183

151184
- [Microsoft Desired State Configuration overview][04]

powershell-adapter/Tests/native_and_powershell.dsc.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
# Licensed under the MIT License.
33

44
# Example configuration mixing native app resources with classic PS resources
5+
# The example assumes you have a DSC resource module named TestFileDscResource and PowerShellGet v2.2.5 installed in C:\Program Files\WindowsPowerShell\Modules
56
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
67
resources:
78
- name: Get info from classic DSC resources
8-
type: Microsoft.DSC/PowerShell
9+
type: Microsoft.Windows/WindowsPowerShell
910
properties:
1011
resources:
1112
- name: Get PS Repository Info
12-
type: PowerShellGet/MSFT_PSRepository
13+
type: PowerShellGet/PSRepository
1314
properties:
1415
Name: PSGallery
1516
- name: Check File

0 commit comments

Comments
 (0)