diff --git a/CHANGELOG.md b/CHANGELOG.md index 65b0f8be87..fb9ac59df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Change log for Microsoft365DSC +# 1.24.207.2 + +* TeamsAppSetupPolicy + * Changed the logic to retrieve arrays of Ids in the Get method. +* MISC + * Drift Logging + * Now includes the full list of parameters for the current values. + * Telemetry + * Added a new M365DSCTelemetryEventId parameter to track duplication of events. + # 1.24.207.1 * IntuneDeviceEnrollmentPlatformRestriction diff --git a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 index 45bb8020db..b45581ddf2 100644 --- a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 +++ b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft Corporation # -# Generated on: 2024-02-07 +# Generated on: 2024-02-08 @{ @@ -11,7 +11,7 @@ # RootModule = '' # Version number of this module. - ModuleVersion = '1.24.207.1' + ModuleVersion = '1.24.207.2' # Supported PSEditions # CompatiblePSEditions = @() @@ -140,7 +140,14 @@ IconUri = 'https://github.com/microsoft/Microsoft365DSC/blob/Dev/Modules/Microsoft365DSC/Dependencies/Images/Logo.png?raw=true' # ReleaseNotes of this module - ReleaseNotes = '* IntuneDeviceEnrollmentPlatformRestriction + ReleaseNotes = '* TeamsAppSetupPolicy + * Changed the logic to retrieve arrays of Ids in the Get method. + * MISC + * Drift Logging + * Now includes the full list of parameters for the current values. + * Telemetry + * Added a new M365DSCTelemetryEventId parameter to track duplication of events. + * IntuneDeviceEnrollmentPlatformRestriction * Added Priority parameter FIXES [#4081](https://github.com/microsoft/Microsoft365DSC/issues/4081) * SCDLPComplianceRule diff --git a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 index f9d9554dd2..9aebe5015d 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 @@ -5,7 +5,7 @@ This function gets the Application Insights key to be used for storing telemetry .Functionality Internal, Hidden #> -function Get-ApplicationInsightsTelemetryClient +function Get-M365DSCApplicationInsightsTelemetryClient { [CmdletBinding()] param() @@ -53,13 +53,12 @@ function Add-M365DSCTelemetryEvent [System.Collections.Generic.Dictionary[[System.String], [System.Double]]] $Metrics ) - $TelemetryEnabled = [System.Environment]::GetEnvironmentVariable('M365DSCTelemetryEnabled', ` [System.EnvironmentVariableTarget]::Machine) if ($null -eq $TelemetryEnabled -or $TelemetryEnabled -eq $true) { - $TelemetryClient = Get-ApplicationInsightsTelemetryClient + $TelemetryClient = Get-M365DSCApplicationInsightsTelemetryClient try { @@ -189,27 +188,60 @@ function Add-M365DSCTelemetryEvent [array]$version = (Get-Module 'Microsoft365DSC').Version | Sort-Object -Descending $Data.Add('M365DSCVersion', $version[0].ToString()) - # Get Dependencies loaded versions + # LCM Metadata Information try { - $currentPath = Join-Path -Path $PSScriptRoot -ChildPath '../' -Resolve - $manifest = Import-PowerShellDataFile "$currentPath/Microsoft365DSC.psd1" - $dependencies = $manifest.RequiredModules + $LCMInfo = Get-DscLocalConfigurationManager -ErrorAction Stop + + $certificateConfigured = $false + if (-not [System.String]::IsNullOrEmpty($LCMInfo.CertificateID)) + { + $certificateConfigured = $true + } - $dependenciesContent = '' - foreach ($dependency in $dependencies) + $partialConfiguration = $false + if (-not [System.String]::IsNullOrEmpty($LCMInfo.PartialConfigurations)) + { + $partialConfiguration = $true + } + $Data.Add('LCMUsesPartialConfigurations', $partialConfiguration) + $Data.Add('LCMCertificateConfigured', $certificateConfigured) + $Data.Add('LCMConfigurationMode', $LCMInfo.ConfigurationMode) + $Data.Add('LCMConfigurationModeFrequencyMins', $LCMInfo.ConfigurationModeFrequencyMins) + $Data.Add('LCMRefreshMode', $LCMInfo.RefreshMode) + $Data.Add('LCMState', $LCMInfo.LCMState) + $Data.Add('LCMStateDetail', $LCMInfo.LCMStateDetail) + + if ($Global:M365DSCExportInProgress) + { + $Data.Add('M365DSCOperation', 'Export') + } + elseif ($LCMInfo.LCMStateDetail -eq 'LCM is performing a consistency check.') { - $dependenciesContent += Get-Module $dependency.ModuleName | Out-String + $Data.Add('M365DSCOperation', 'MonitoringScheduled') + } + elseif ($LCMInfo.LCMStateDetail -eq 'LCM is testing node against the configuration.') + { + $Data.Add('M365DSCOperation', 'MonitoringManual') + } + elseif ($LCMInfo.LCMStateDetail -eq 'LCM is applying a new configuration.') + { + $Data.Add('M365DSCOperation', 'ApplyingConfiguration') + } + else + { + $Data.Add('M365DSCOperation', 'Undetermined') } - $Data.Add('DependenciesVersion', $dependenciesContent) } catch { Write-Verbose -Message $_ } + $M365DSCTelemetryEventId = (New-GUID).ToString() + $Data.Add('M365DSCTelemetryEventId', $M365DSCTelemetryEventId) + $TelemetryClient.TrackEvent($Type, $Data, $Metrics) - $TelemetryClient.Flush() } catch { diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index aca92258d4..d83b9d82c6 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -919,6 +919,7 @@ function Test-M365DSCParameterState } $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues $driftedData.Add('Tenant', $TenantName) + $driftedData.Add('Resource', $source.Split('_')[1]) Add-M365DSCTelemetryEvent -Type 'DriftInfo' -Data $driftedData #endregion $EventMessage.Append(" " + $DriftedParameters.$key + "`r`n") | Out-Null @@ -943,6 +944,17 @@ function Test-M365DSCParameterState $EventMessage.Append(" $Value`r`n") | Out-Null } $EventMessage.Append(" `r`n") | Out-Null + $EventMessage.Append(" `r`n") | Out-Null + foreach ($Key in $CurrentValues.Keys) + { + $Value = $CurrentValues.$Key + if ([System.String]::IsNullOrEmpty($Value)) + { + $Value = "`$null" + } + $EventMessage.Append(" $Value`r`n") | Out-Null + } + $EventMessage.Append(" `r`n") | Out-Null $EventMessage.Append('') | Out-Null Add-M365DSCEvent -Message $EventMessage.ToString() -EventType 'Drift' -EntryType 'Warning' ` @@ -970,9 +982,6 @@ function Test-M365DSCParameterState -EventID 2 -Source $Source } - #region Telemetry - Add-M365DSCTelemetryEvent -Data $data - #endregion return $returnValue } @@ -1164,7 +1173,7 @@ function Export-M365DSCConfiguration [Switch] $Validate ) - + $Global:M365DSCExportInProgress = $true $Global:MaximumFunctionCount = 32767 # Define the exported resource instances' names Global variable @@ -1348,6 +1357,7 @@ function Export-M365DSCConfiguration # Clear the exported resource instances' names Global variable $Global:M365DSCExportedResourceInstancesNames = $null + $Global:M365DSCExportInProgress = $false } $Script:M365DSCDependenciesValidated = $false