Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

MSFT_AADUser.ps1

Open PSNobbi opened this issue 1 year ago • 2 comments

Description of the issue

During the import with the AADUser, the license is not assigned, resulting in an error. After some back and forth, I also discovered that the issue is related to the Set-MgUserLicense module.

Help:

https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3201#issuecomment-2751108343

Microsoft 365 DSC Version

V 1.25.319.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

https://github.com/microsoft/Microsoft365DSC/blob/id/Modules/Microsoft365DSC/DSCResources/MSFT_AADUser/MSFT_AADUser.psm1#L572

        AADUser "[email protected]"
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            DisplayName           = "User Muster";
            Ensure                = "Present";
            FirstName             = "User";
            LastName              = "Muster";
            LicenseAssignment     = @("SPE_E3");
            MemberOf              = @();
            PasswordNeverExpires  = $True;
            PasswordPolicies      = "DisablePasswordExpiration";
            Roles                 = @();
            TenantId              = $OrganizationName;
            UsageLocation         = "DE";
            UserPrincipalName     = "[email protected]";
            UserType              = "Member";
        }

Verbose logs showing the problem

[Request_BadRequest] : Cannot convert the literal '' to the expected type 'Edm.Guid'.
    + CategoryInfo          : InvalidOperation: ({ UserId = [email protected] }:) [], CimException
    + FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.SetMgUserLicense_AssignExpanded
    + PSComputerName        : localhost
[Request_BadRequest] : Cannot convert the literal '' to the expected type 'Edm.Guid'.
    + CategoryInfo          : InvalidOperation: ({ UserId = [email protected] }:) [], CimException
    + FullyQualifiedErrorId : Request_BadRequest,Microsoft.Graph.PowerShell.Cmdlets.SetMgUserLicense_AssignExpand
   ed
    + PSComputerName        : localhost


Environment Information + PowerShell Version

Name                           Value                                                                                                                                                                                                                     
----                           -----                                                                                                                                                                                                                     
PSVersion                      5.1.20348.2849                                                                                                                                                                                                            
PSEdition                      Desktop                                                                                                                                                                                                                   
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                   
BuildVersion                   10.0.20348.2849                                                                                                                                                                                                           
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                           
WSManStackVersion              3.0                                                                                                                                                                                                                       
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                       
SerializationVersion           1.1.0.1                                                                                                                                                                                                                   

PSNobbi avatar Mar 26 '25 14:03 PSNobbi

This will be fixed with the next update of the Microsoft Graph SDK.

FabienTschanz avatar Apr 20 '25 21:04 FabienTschanz

Should be fixed with #6038.

FabienTschanz avatar Apr 21 '25 15:04 FabienTschanz