Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

EXOManagementRoleAssignment: REGRESSION - Does not work if a soft-deleted identically named Administrative Unit exists (see #3064)

Open Borgquite opened this issue 1 year ago • 0 comments

Description of the issue

@NikCharlebois This commit, just released in 1.24.424.1

https://github.com/microsoft/Microsoft365DSC/commit/b8c9d3138ba6ae31f1f389bac7852ce12a94f3dd

Is a regression. If you remember, we moved to the Graph way of picking up AdministrativeUnits in #3113 to fix #3064.

I think you also forgot to change 'Name' back to 'Id' but regardless Graph is the way ahead.

Please can you revert? Perhaps we also need a comment in the code to remind why it's using Graph?

Microsoft 365 DSC Version

1.24.424.1

Which workloads are affected

Exchange Online

The DSC configuration

- Manually create an Administrative Unit called 'Test-Unit'
- Delete it
- Wait for it to be visible in Get-AdministrativeUnit in Exchange Online PowerShell


$credsCredential = Get-Credential

Configuration Example
{
    Import-DscResource -ModuleName Microsoft365DSC

    node localhost
    {
        AADAdministrativeUnit 'TestUnit'
        {
            Credential                    = $credsCredential;
            DisplayName                   = "Test-Unit";
            Ensure                        = "Present";
        }
        EXODistributionGroup 'MailEnabledSecurityGroup'
        {
            Credential = $credsCredential;
            Name = "Test-Group";
            Alias = "Test-Group";
            Type = "Security";
            Ensure = "Present";
        }
        EXOManagementRoleAssignment 'AssignManagementRole'
        {
            Credential           = $credsCredential;
            Ensure               = "Present";
            Name                 = "MyManagementRoleAssignment";
            Role                 = "Mail Recipients";
            SecurityGroup        = "Test-Group";
            RecipientAdministrativeUnitScope = "Test-Unit"
        }
    }
}

$cd = @{
    AllNodes = @(
        @{
            NodeName = 'localhost'
            PSDscAllowPlainTextPassword = $true
        }
    )
}

Verbose logs showing the problem

VERBOSE: [COMPUTERNAME]: LCM:  [ Start  Resource ]  [[EXOManagementRoleAssignment]AssignManagementRole]                                                                               VERBOSE: [COMPUTERNAME]: LCM:  [ Start  Test     ]  [[EXOManagementRoleAssignment]AssignManagementRole]                                                                               VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Testing Management Role Assignment for MyManagementRoleAssignment             
VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Getting Management Role Assignment for MyManagementRoleAssignment
VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Management Role Assignment MyManagementRoleAssignment does not exist.
VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Current Values: ApplicationId=***;
CertificateThumbprint=***; Ensure=Absent; Name=MyManagementRoleAssignment; RecipientAdministrativeUnitScope=Test-Unit; Role=Mail Recipients;   
SecurityGroup=Test-Group; TenantId=***; Verbose=True
VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Target Values: ApplicationId=***;
CertificateThumbprint=***; Ensure=Present; Name=MyManagementRoleAssignment; RecipientAdministrativeUnitScope=Test-Unit; Role=Mail Recipients;  
SecurityGroup=Test-Group; TenantId=***; Verbose=True
VERBOSE: [COMPUTERNAME]:                            [[EXOManagementRoleAssignment]AssignManagementRole] Test-TargetResource returned False
VERBOSE: [COMPUTERNAME]: LCM:  [ End    Test     ]  [[EXOManagementRoleAssignment]AssignManagementRole] False in 1.0510 seconds.
VERBOSE: [COMPUTERNAME]: LCM:  [ End    Resource ]  [[EXOManagementRoleAssignment]AssignManagementRole]

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : en-GB
OsMuiLanguages       : {en-GB, en-US}

Borgquite avatar Apr 25 '24 10:04 Borgquite