O365AdminAuditLogConfig: Set-TargetResource not working
Details of the scenario you tried and the problem that is occurring
Hi,
we've been wondering for a while now why M365DSC wouldn't turn on "UnifiedAuditLogIngestionEnabled" for us, although we had the corresponding config set up. This was stupid and wrong, please disregard that>>>>Turns out: Get-TargetResource and Set-TargetResource are calling the functions Get-AdminAuditLogConfig and Set-AdminAuditLogConfig, respectively. But these functions only exist as mock code in "\Tests\Unit\Microsoft365DSC\Microsoft365DSC.O365AdminAuditLogConfig.Tests.ps1"! They were never implemented, it seems. So, this DSC resource does nothing, actually. The logs will always only show the mock results being returned.<<< Edit: Correct logs below now. We ran Apply-DscConfig over a week ago already, and again today - the feature won't come on.
Verbose logs showing the problem
2021-04-09T15:25:36.7928265Z VERBOSE: [fv-az98-697]: LCM: [ Start Resource ] [[O365AdminAuditLogConfig]UnifiedAuditLog] 2021-04-09T15:25:36.7929250Z VERBOSE: [fv-az98-697]: LCM: [ Start Test ] [[O365AdminAuditLogConfig]UnifiedAuditLog] 2021-04-09T15:25:36.7930060Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Importing the module 2021-04-09T15:25:36.7930769Z MSFT_O365AdminAuditLogConfig in force mode. 2021-04-09T15:25:36.7956447Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Testing configuration for 2021-04-09T15:25:36.7957751Z Office 365 Audit Log 2021-04-09T15:25:36.7982308Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Getting configuration for 2021-04-09T15:25:36.7983516Z Office 365 Audit Log 2021-04-09T15:25:44.7501057Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Current Values: 2021-04-09T15:25:44.7506533Z Ensure=Present; GlobalAdminAccount=System.Management.Automation.PSCredential; IsSingleInstance=Yes; 2021-04-09T15:25:44.7507469Z UnifiedAuditLogIngestionEnabled=Disabled 2021-04-09T15:25:44.7508216Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Target Values: 2021-04-09T15:25:44.7509365Z Ensure=Present; GlobalAdminAccount=System.Management.Automation.PSCredential; IsSingleInstance=Yes; 2021-04-09T15:25:44.7510105Z UnifiedAuditLogIngestionEnabled=Enabled; Verbose=True 2021-04-09T15:25:44.9683501Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Test-TargetResource 2021-04-09T15:25:44.9693664Z returned False 2021-04-09T15:25:44.9788111Z VERBOSE: [fv-az98-697]: LCM: [ End Test ] [[O365AdminAuditLogConfig]UnifiedAuditLog] in 8.1800 seconds. 2021-04-09T15:25:44.9800212Z VERBOSE: [fv-az98-697]: LCM: [ Start Set ] [[O365AdminAuditLogConfig]UnifiedAuditLog] 2021-04-09T15:25:44.9820885Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Importing the module 2021-04-09T15:25:45.0104638Z MSFT_O365AdminAuditLogConfig in force mode. 2021-04-09T15:25:45.0142469Z VERBOSE: [fv-az98-697]: [[O365AdminAuditLogConfig]UnifiedAuditLog] Setting configuration for 2021-04-09T15:25:45.0143190Z Office 365 Audit Log 2021-04-09T15:25:53.6204035Z VERBOSE: [fv-az98-697]: LCM: [ End Set ] [[O365AdminAuditLogConfig]UnifiedAuditLog] in 8.6520 seconds. 2021-04-09T15:25:53.6208348Z VERBOSE: [fv-az98-697]: LCM: [ End Resource ] [[O365AdminAuditLogConfig]UnifiedAuditLog]
Suggested solution to the issue
No idea...
The DSC configuration that is used to reproduce the issue (as detailed as possible)
O365AdminAuditLogConfig UnifiedAuditLog
{
IsSingleInstance = "Yes"
Ensure = "Present"
UnifiedAuditLogIngestionEnabled = "Enabled"
GlobalAdminAccount = $Credsglobaladmin
}
The operating system the target node is running
Azure DevOps release agent
Version of the DSC module that was used ('dev' if using current dev branch)
dev
I don't believe that the moc cmdlets can be called outside a test.
What you are seing in the verbose output is the result of Test-TargetResource, which "tests"/checks your environment configuration with your local configuration and returns true if the two configurations are the same.
In your verbose output, you can see the current values of your enviroment:
Current Values:Ensure=Present; GlobalAdminAccount=System.Management.Automation.PSCredential; IsSingleInstance=Yes; UnifiedAuditLogIngestionEnabled=Enabled
And your local configuration values:
Target Values:Ensure=Present; GlobalAdminAccount=System.Management.Automation.PSCredential; IsSingleInstance=Yes; UnifiedAuditLogIngestionEnabled=Enabled; Verbose=True
The two configurations match, so nothing needs to be changed 😉
It should be noted that changing this specific configuration takes a while before the changes is actually effective: https://docs.microsoft.com/en-us/microsoft-365/compliance/turn-audit-log-search-on-or-off?view=o365-worldwide#use-powershell-to-turn-on-audit-log-search
Alright, after some more digging I see I was clearly mistaken regarding the missing implementation - the O365AdminAuditLogConfig resource is calling into the EXO PowerShell module for executing Get-AdminAuditLogConfig and Set-AdminAuditLogConfig. Please excuse my confusion there.
@Swampen
In your verbose output, you can see the current values of your enviroment:
The logs above were for the wrong tenant, sorry. Let me edit my post and add the correct one. It shows that DSC clearly sees the audit log as disabled and tries to enable it - but later Test-DscConfig runs show the value still as "disabled" and in the UI it never changes as well. The logs I'll post are from today, but we've been running the Apply-DscConfig process with the same exact config over a week ago - and still no change.
I'm glad we cleared up the confusion 😊
Could you try to run Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true and see if you get any error in the output?
Hi @Swampen,
I've tried Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $true and Set-AdminAuditLogConfig -UnifiedAuditLogIngestionEnabled $false now. Both work without errors, and I can see the feature being enabled and disabled as expected in the UI.
So it seems to be broken only when being called from M365DSC. Any guesses what it might be?
I have submitted a pull request now that will fix this issue