Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

AADServicePrincipal: AppRoleAssignedTo parameter referencing issue

Open abhisri13 opened this issue 1 year ago • 0 comments

Description of the issue

DSC running into errors when referencing AppRoleAssignedTo parameter for AADServicePrincipal.

We are getting the below error:

##[error]Cannot bind argument to parameter 'ReferenceObject' because it is null.
    + CategoryInfo          : InvalidData: (:) [], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CompareObje 
   ctCommand
    + PSComputerName        : localhost

Upon further investigation it looks like the module has a bug at this location in the module.

Microsoft 365 DSC Version

V1.25.122.2

Which workloads are affected

other

The DSC configuration

AADServicePrincipal 'AADServicePrincipal-SERVICEPRINCIPALNAME' {
    DependsOn                   = @(
                '[AADApplication]AADApplication-Microsoft365DSC'
    )
    AppId                       = 'SERVICE-PRINCIPAL-ID'
    AppRoleAssignmentRequired   = $False;
    DisplayName                 = 'SERVICEPRINCIPALNAME'
    Ensure                      = 'Present'
    ServicePrincipalType        = 'Application'
    AppRoleAssignedTo           = @(
        MSFT_AADServicePrincipalRoleAssignment {
            PrincipalType = 'User'
            Identity      = 'tenantUser'
        }
        MSFT_AADServicePrincipalRoleAssignment {
            PrincipalType = 'Group'
            Identity      = 'tenantGroup'
        }
    );
    AccountEnabled              = $True;
    ApplicationId               = $ApplicationId
    TenantId                    = $TenantId
    CertificateThumbprint       = $Thumbprint
}

Verbose logs showing the problem

VERBOSE: [[AADServicePrincipal]AADServicePrincipal-SERVICEPRINCIPAL::[AzureAD]AzureAD_Configuration] Performing the operation "Update-MgServicePrincipal_UpdateExpanded" on target
 "Call remote 'PATCH /servicePrincipals/{servicePrincipal-id}' operation".
##[error]Cannot bind argument to parameter 'ReferenceObject' because it is null.
    + CategoryInfo          : InvalidData: (:) [], CimException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CompareObje 
   ctCommand
    + PSComputerName        : localhost

Environment Information + PowerShell Version

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}




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

abhisri13 avatar Feb 03 '25 22:02 abhisri13