From 6ce3d578f41e1d63f8af099a49cac5e5af9fc0da Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Fri, 5 Sep 2025 15:25:50 +0200 Subject: [PATCH 1/5] Add known issue with Windows PowerShell adapter --- docs/troubleshooting/known-issues.md | 33 +++++++++++++++++++ .../Tests/native_and_powershell.dsc.yaml | 5 +-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/troubleshooting/known-issues.md b/docs/troubleshooting/known-issues.md index c0b6817a9..57e6e7dba 100644 --- a/docs/troubleshooting/known-issues.md +++ b/docs/troubleshooting/known-issues.md @@ -146,6 +146,39 @@ 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: "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] diff --git a/powershell-adapter/Tests/native_and_powershell.dsc.yaml b/powershell-adapter/Tests/native_and_powershell.dsc.yaml index 88a2a25fd..f1dd2ed7a 100644 --- a/powershell-adapter/Tests/native_and_powershell.dsc.yaml +++ b/powershell-adapter/Tests/native_and_powershell.dsc.yaml @@ -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 From a8ae081417ae5121e342bb5e31b228810ddc9a65 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 6 Sep 2025 07:28:21 +0200 Subject: [PATCH 2/5] Update comment --- docs/troubleshooting/known-issues.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/troubleshooting/known-issues.md b/docs/troubleshooting/known-issues.md index 57e6e7dba..917dc42af 100644 --- a/docs/troubleshooting/known-issues.md +++ b/docs/troubleshooting/known-issues.md @@ -150,7 +150,11 @@ When executing `dsc.exe` commands in Windows PowerShell: 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: "Cannot bind argument to parameter 'Path' because it is an empty string." +appear: + +```console +Cannot bind argument to parameter 'Path' because it is an empty string. +``` ### Problem details From 464eee6daababcecdb18578ee7b3ebfb50422a5c Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Fri, 5 Sep 2025 15:25:50 +0200 Subject: [PATCH 3/5] Add known issue with Windows PowerShell adapter --- docs/troubleshooting/known-issues.md | 33 +++++++++++++++++++ .../Tests/native_and_powershell.dsc.yaml | 5 +-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/docs/troubleshooting/known-issues.md b/docs/troubleshooting/known-issues.md index c0b6817a9..57e6e7dba 100644 --- a/docs/troubleshooting/known-issues.md +++ b/docs/troubleshooting/known-issues.md @@ -146,6 +146,39 @@ 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: "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] diff --git a/powershell-adapter/Tests/native_and_powershell.dsc.yaml b/powershell-adapter/Tests/native_and_powershell.dsc.yaml index 88a2a25fd..f1dd2ed7a 100644 --- a/powershell-adapter/Tests/native_and_powershell.dsc.yaml +++ b/powershell-adapter/Tests/native_and_powershell.dsc.yaml @@ -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 From f2b131946d689db0fd38dbd19005a50c0354c174 Mon Sep 17 00:00:00 2001 From: "G.Reijn" Date: Sat, 6 Sep 2025 07:28:21 +0200 Subject: [PATCH 4/5] Update comment --- docs/troubleshooting/known-issues.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/troubleshooting/known-issues.md b/docs/troubleshooting/known-issues.md index 57e6e7dba..917dc42af 100644 --- a/docs/troubleshooting/known-issues.md +++ b/docs/troubleshooting/known-issues.md @@ -150,7 +150,11 @@ When executing `dsc.exe` commands in Windows PowerShell: 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: "Cannot bind argument to parameter 'Path' because it is an empty string." +appear: + +```console +Cannot bind argument to parameter 'Path' because it is an empty string. +``` ### Problem details From 4890a0e795148846398b05eb6ad20ce548a7cb70 Mon Sep 17 00:00:00 2001 From: GijsR Date: Tue, 9 Sep 2025 14:48:05 +0200 Subject: [PATCH 5/5] Remove original issue --- docs/troubleshooting/known-issues.md | 37 ---------------------------- 1 file changed, 37 deletions(-) diff --git a/docs/troubleshooting/known-issues.md b/docs/troubleshooting/known-issues.md index 917dc42af..c0b6817a9 100644 --- a/docs/troubleshooting/known-issues.md +++ b/docs/troubleshooting/known-issues.md @@ -146,43 +146,6 @@ 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]