diff --git a/CHANGELOG.md b/CHANGELOG.md index f0a698066b..ce7e9958d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -97,7 +97,8 @@ * Major changes to the export process where resource instances will now be assigned a meaningful nam that will follow the ResourceName-PrimaryKey convention. * Added a fix making sure that the progress bar "Scanning dependencies" is no longer displayed after the operation is completed. - + * Changed configuration drift reporting to event log to include the instance name as the source. + FIXES [#2981](https://github.com/microsoft/Microsoft365DSC/issues/2981) # 1.23.322.1 diff --git a/Modules/Microsoft365DSC/Modules/M365DSCLogEngine.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCLogEngine.psm1 index ca64bc02be..8a26608e57 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCLogEngine.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCLogEngine.psm1 @@ -691,14 +691,13 @@ function Get-M365DSCCurrentResourceInstanceNameFromLogs [System.String] $ResourceName ) - try { - $allEvents = Get-WinEvent -LogName "Microsoft-windows-dsc/operational" -MaxEvents 25 + $allEvents = Get-WinEvent -LogName "Microsoft-windows-dsc/operational" -MaxEvents 10 foreach ($event in $allEvents) { $message = $event.Message - $stringToFind = "Resource execution sequence :: [$ResourceName]" + $stringToFind = "Resource execution sequence :: [$($ResourceName.Split('_')[1])]" $start = $message.IndexOf($stringToFind) if ($start -ge 0) { @@ -717,6 +716,7 @@ function Get-M365DSCCurrentResourceInstanceNameFromLogs Export-ModuleMember -Function @( 'Add-M365DSCEvent', 'Export-M365DSCDiagnosticData', + 'Get-M365DSCCurrentResourceInstanceNameFromLogs', 'New-M365DSCLogEntry', 'Get-M365DSCNotificationEndPointRegistration', 'New-M365DSCNotificationEndPointRegistration', diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 364c7e227b..525aa027d7 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -861,7 +861,7 @@ function Test-M365DSCParameterState $currentInstanceName = $Source } $EventMessage = "`r`n" - $EventMessage += " `r`n" + $EventMessage += " `r`n" $EventMessage += " `r`n" foreach ($key in $DriftedParameters.Keys)