Skip to content
Open
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
37 changes: 37 additions & 0 deletions docs/troubleshooting/known-issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,43 @@ When executing `dsc.exe` commands in Windows PowerShell:
- Use `ConvertTo-Json` without the `-Compress` parameter.
- Consider using PowerShell 7+ for improved JSON handling compatibility.

## Zero results when listing resources with Windows PowerShell adapter

When running `dsc resource list --adapter Microsoft.Windows/WindowsPowerShell`, you
may see zero resources returned. In trace or debug logs, an error like the following can
appear:

```console
Cannot bind argument to parameter 'Path' because it is an empty string.
```

### Problem details

This issue occurs when the `PSModulePath` environment variable ends with a trailing path
separator (`;`). The PSDesiredStateConfiguration v1.1 module doesn't handle the empty path
segment and throws an error while enumerating modules, which results in zero resources being
listed by `dsc resource list`.

### Resolution steps

Remove any trailing path separators from `PSModulePath` so there are no empty entries:

```powershell
# Show current PSModulePath entries (note any empty items at the end)
$env:PSModulePath -split ';'

# Remove empty entries and rejoin (session only)
$env:PSModulePath = ($env:PSModulePath -split ';' | Where-Object { $_ -ne '' }) -join ';'

# Re-run the listing
dsc resource list --adapter Microsoft.Windows/WindowsPowerShell
```

### Recommendation

Avoid trailing semicolons in `PSModulePath` variable. Ensure all path segments are non-empty
to prevent PSDSC 1.1 from encountering empty paths during module discovery.

## See also

- [Microsoft Desired State Configuration overview][04]
Expand Down
5 changes: 3 additions & 2 deletions powershell-adapter/Tests/native_and_powershell.dsc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
# Licensed under the MIT License.

# Example configuration mixing native app resources with classic PS resources
# The example assumes you have a DSC resource module named TestFileDscResource and PowerShellGet v2.2.5 installed in C:\Program Files\WindowsPowerShell\Modules
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Get info from classic DSC resources
type: Microsoft.DSC/PowerShell
type: Microsoft.Windows/WindowsPowerShell
properties:
resources:
- name: Get PS Repository Info
type: PowerShellGet/MSFT_PSRepository
type: PowerShellGet/PSRepository
properties:
Name: PSGallery
- name: Check File
Expand Down
Loading