msgraph-sdk-powershell icon indicating copy to clipboard operation
msgraph-sdk-powershell copied to clipboard

New-MgDeviceManagementDeviceConfiguration always throws Cannot create an abstract class.

Open michaeldcanady opened this issue 9 months ago • 3 comments

Describe the bug

I am trying to create a Windows10 Custom Configuration but It keeps returning "Cannot create an abstract class"

Expected behavior

Create and return the Device Configuration

How to reproduce

  1. Execute Connect-MgGraph -Scopes @("deviceManagement.ReadWrite.All")
  2. Create body hashtable
$body = @{
        "@odata.type" = "#microsoft.graph.windows10CustomConfiguration"
        description   = "Description value"
        displayName   = "Display Name value"
        version       = 7
        omaSettings   = @(
            @{
                "@odata.type" = "microsoft.graph.omaSetting"
                displayName   = "Display Name value"
                description   = "Description value"
                omaUri        = "Oma Uri value"
            }
        )
    }
  1. Execute New-MgDeviceManagementDeviceConfiguration -BodyParameter $body

SDK Version

2.16.0

Latest version known to work for scenario above?

No response

Known Workarounds

No response

Debug output

Click to expand log ```
</details>


### Configuration

- PSVersion: 7.4.1
- PSEdition: Core
- GitCommitId: 7.4.1
- 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

### Other information

_No response_

michaeldcanady avatar May 14 '24 18:05 michaeldcanady

Issue was use of abstract type "microsoft.graph.omaSetting" needs to be subtype. Would probably be helpful to make error message more clear.

michaeldcanady avatar May 14 '24 18:05 michaeldcanady

Is this still an open Bug or is there already a solution?

MaxCl93 avatar Jul 24 '24 13:07 MaxCl93

I believe the “bug” portion is incorrect, it turns out the issue was me using the “omasetting” type, it’s abstract, so might be better as a “feature request” or something to make the error code more descriptive. Ex: “ Cannot create an abstract class omasetting”

michaeldcanady avatar Jul 24 '24 13:07 michaeldcanady