PowerShell / DSC

This repo is for the DSC v3 project
MIT License
133 stars 22 forks source link

Resource list for Microsoft.DSC/PowerShell failing to list resources. #447

Closed theJasonHelmick closed 3 weeks ago

theJasonHelmick commented 3 weeks ago

Prerequisites

Summary

Attempting to list resources from Microsoft.DSC/PowerShell as listed here in the docs: https://learn.microsoft.com/en-us/powershell/dsc/reference/cli/resource/list?view=dsc-3.0#example-6---list-resources-for-a-specific-adapter

Fails to list any resources, only lists two warnings.

Tested on Server 2025 Preview X64 and Win 11 Arm.

Steps to reproduce

dsc resource list --adapter Microsoft.DSC/PowerShell

Screenshot 2024-06-05 at 12 05 51 PM

Expected behavior

List of resources

Actual behavior

Returns two warnings pasted below.

Error details

2024-06-05T19:21:37.792323Z  WARN Failed to parse resource: {"type":"PackageManagement/PackageManagement","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement\\MSFT_PackageManagement.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."} -> invalid type: null, expected a sequence at line 1 column 476
2024-06-05T19:21:37.792735Z  WARN Failed to parse resource: {"type":"PackageManagement/PackageManagementSource","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource\\MSFT_PackageManagementSource.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."} -> invalid type: null, expected a sequence at line 1 column 500

Environment data

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

3.0.0-Preview.7

Visuals

No response

anmenaga commented 3 weeks ago

@theJasonHelmick please provide additiona debug info: 1) output of get-module -ListAvailable -Name PackageManagement 2) output of dsc -l trace resource list * -a Microsoft.DSC/PowerShell

theJasonHelmick commented 3 weeks ago

@anmenaga - Thank you for taking a look :)

get-module -ListAvailable -Name PackageManagement  

    Directory: C:\program files\powershell\7\Modules   ModuleType Version    PreRelease Name                                PSEdition ExportedCommands ---------- -------    ---------- ----                                --------- ---------------- Script     1.4.8.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…       Directory: C:\Program Files\WindowsPowerShell\Modules   ModuleType Version    PreRelease Name                                PSEdition ExportedCommands ---------- -------    ---------- ----                                --------- ---------------- Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…

  dsc -l trace resource list * -a Microsoft.DSC/PowerShell  


 
2024-06-06T14:53:34.147282Z DEBUG dsc: 36: Running dsc 3.0.0-preview.7
2024-06-06T14:53:34.147636Z DEBUG dsc_lib::discovery::command_discovery: 82: Listing resources with type_name_filter/adapter_name_filter: */Microsoft.DSC/PowerShell
2024-06-06T14:53:34.147935Z DEBUG dsc_lib::discovery::command_discovery: 95: Using regex ^.*?$ as filter for resource type
2024-06-06T14:53:34.148551Z TRACE dsc_lib::discovery::command_discovery: 41: DSC_RESOURCE_PATH not set, trying PATH
2024-06-06T14:53:34.149537Z DEBUG dsc_lib::discovery::command_discovery: 44: Using PATH: "C:\\Program Files\\PowerShell\\7;C:\\Program Files\\Parallels\\Parallels Tools\\Applications;C:\\Program Files\\Microsoft SDKs\\Azure\\CLI2\\wbin;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\WINDOWS\\System32\\OpenSSH\\;C:\\Program Files\\PowerShell\\7;C:\\Program Files\\AzureConnectedMachineAgent\\;C:\\Program Files\\Git\\cmd;C:\\Users\\jahelmic\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Users\\jahelmic\\.azure\\bin\\shell-copilot;c:\\dsc;C:\\Users\\jahelmic\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
2024-06-06T14:53:34.150245Z DEBUG dsc_lib::discovery::command_discovery: 58: Adding exe home to path: c:\dsc
2024-06-06T14:53:34.150596Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "c:\\dsc"
2024-06-06T14:53:34.201750Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Program Files\\PowerShell\\7"
2024-06-06T14:53:34.221071Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Program Files\\Parallels\\Parallels Tools\\Applications"
2024-06-06T14:53:34.222249Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Program Files\\Microsoft SDKs\\Azure\\CLI2\\wbin"
2024-06-06T14:53:34.223125Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\WINDOWS\\system32"
2024-06-06T14:53:34.680296Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\WINDOWS"
2024-06-06T14:53:34.688843Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\WINDOWS\\System32\\Wbem"
2024-06-06T14:53:34.745169Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\"
2024-06-06T14:53:34.748265Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\WINDOWS\\System32\\OpenSSH\\"
2024-06-06T14:53:34.750833Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Program Files\\AzureConnectedMachineAgent\\"
2024-06-06T14:53:34.760763Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Program Files\\Git\\cmd"
2024-06-06T14:53:34.762067Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Users\\jahelmic\\AppData\\Local\\Microsoft\\WindowsApps"
2024-06-06T14:53:34.768465Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Users\\jahelmic\\.azure\\bin\\shell-copilot"
2024-06-06T14:53:34.779565Z DEBUG dsc_lib::discovery::command_discovery: 106: Searching in "C:\\Users\\jahelmic\\AppData\\Local\\Programs\\Microsoft VS Code\\bin"
2024-06-06T14:53:34.780195Z DEBUG dsc_lib::discovery::command_discovery: 143: Found 0 matching non-adapter-based resources
2024-06-06T14:53:34.780388Z DEBUG dsc_lib::discovery::command_discovery: 147: Using regex ^Microsoft\.DSC/PowerShell$ as filter for adapter name
2024-06-06T14:53:34.780790Z DEBUG dsc_lib::discovery::command_discovery: 159: Enumerating resources for adapter 'Microsoft.DSC/PowerShell'
2024-06-06T14:53:34.781058Z DEBUG dsc_lib::dscresources::command_resource: 542: Invoking command 'pwsh' with args Some(["-NoLogo", "-NonInteractive", "-NoProfile", "-Command", "./psDscAdapter/powershell.resource.ps1 List"])
2024-06-06T14:53:44.995551Z TRACE dsc_lib::dscresources::command_resource: 593: STDOUT returned: {"type":"PackageManagement/PackageManagement","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement\\MSFT_PackageManagement.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."}
{"type":"PackageManagement/PackageManagementSource","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource\\MSFT_PackageManagementSource.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."}
 
2024-06-06T14:53:44.995964Z TRACE dsc_lib::dscresources::command_resource: 596: STDERR returned: {"Debug":"jsonInput=@{}"}
Import-Module: Cannot bind argument to parameter 'Name' because it is null.
ConvertFrom-Json: C:\dsc\psDscAdapter\powershell.resource.ps1:25
Line |
  25 |      $inputobj_pscustomobj = $jsonInput | ConvertFrom-Json
     |                                           ~~~~~~~~~~~~~~~~
     | Conversion from JSON failed with error: Unexpected character encountered while parsing value: @. Path '', line
     | 0, position 0.
InvalidOperation: The property 'PSComputerName' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: The property 'RunspaceId' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: The property 'PSShowComputerName' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: The property 'PSComputerName' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: The property 'RunspaceId' cannot be found on this object. Verify that the property exists and can be set.
InvalidOperation: The property 'PSShowComputerName' cannot be found on this object. Verify that the property exists and can be set.
{"Debug":"PSVersion=7.4.2"}
{"Debug":"PSPath=C:\\Program Files\\PowerShell\\7"}
{"Debug":"Module=PSDesiredStateConfiguration"}
{"Debug":"PSModulePath=C:\\Users\\jahelmic\\Documents\\PowerShell\\Modules;C:\\Program Files\\PowerShell\\Modules;c:\\program files\\powershell\\7\\Modules;C:\\Program Files\\WindowsPowerShell\\Modules;C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\Modules"}
 
2024-06-06T14:53:44.997720Z DEBUG dsc_lib::dscresources::command_resource: 28: jsonInput=@{}
2024-06-06T14:53:44.997932Z DEBUG dsc_lib::dscresources::command_resource: 28: PSVersion=7.4.2
2024-06-06T14:53:44.998492Z DEBUG dsc_lib::dscresources::command_resource: 28: PSPath=C:\Program Files\PowerShell\7
2024-06-06T14:53:44.998713Z DEBUG dsc_lib::dscresources::command_resource: 28: Module=PSDesiredStateConfiguration
2024-06-06T14:53:44.998927Z DEBUG dsc_lib::dscresources::command_resource: 28: PSModulePath=C:\Users\jahelmic\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
2024-06-06T14:53:45.001112Z  WARN dsc_lib::discovery::command_discovery: 209: Failed to parse resource: {"type":"PackageManagement/PackageManagement","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement\\MSFT_PackageManagement.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagement","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."} -> invalid type: null, expected a sequence at line 1 column 476
2024-06-06T14:53:45.001446Z  WARN dsc_lib::discovery::command_discovery: 209: Failed to parse resource: {"type":"PackageManagement/PackageManagementSource","kind":"Resource","version":"1.0.0.1","capabilities":["Get","Set","Test"],"path":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource\\MSFT_PackageManagementSource.psm1","directory":"C:\\Program Files\\WindowsPowerShell\\Modules\\PackageManagement\\1.0.0.1\\DSCResources\\MSFT_PackageManagementSource","implementedAs":"ScriptBased","author":"Microsoft Corporation","properties":null,"requireAdapter":"Microsoft.DSC/PowerShell","description":"PackageManagement (a.k.a. OneGet) is a new way to discover and install software packages from around the web."} -> invalid type: null, expected a sequence at line 1 column 500
2024-06-06T14:53:45.001725Z DEBUG dsc_lib::discovery::command_discovery: 215: Adapter 'Microsoft.DSC/PowerShell' listed 0 matching resources
 
Type  Kind  Version  Caps  RequireAdapter  Description
------------------------------------------------------
PS C:\Users\jahelmic>
 
theJasonHelmick commented 3 weeks ago

My mistake! Thanks @anmenaga for the help. I wanted to list non-class based resources from PSDSCResources. The above command I was using is not correct. The correct one currently is: dsc resource list * -a Microsoft.Windows/WindowsPowerShell