From 7788013a5fe06ab2153bf751b8707e2c6deba47a Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 14 Feb 2024 20:53:56 -0500 Subject: [PATCH 1/5] Release 1.24.214.2 --- CHANGELOG.md | 2 +- Modules/Microsoft365DSC/Microsoft365DSC.psd1 | 2 +- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 35b086367c..880bdd44b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change log for Microsoft365DSC -# 1.24.214.1 +# 1.24.214.2 * AADConditionalAccessPolicy * Removed invalid empty string value that was added to the validate set diff --git a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 index 54cd36eb6e..6e3fad6c64 100644 --- a/Modules/Microsoft365DSC/Microsoft365DSC.psd1 +++ b/Modules/Microsoft365DSC/Microsoft365DSC.psd1 @@ -11,7 +11,7 @@ # RootModule = '' # Version number of this module. - ModuleVersion = '1.24.214.1' + ModuleVersion = '1.24.214.2' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 9fbf639bd1..6c6baf3a4c 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -919,7 +919,7 @@ function Test-M365DSCParameterState $driftedData.Add('CurrentValue', [string]($CurrentValues[$key])) $driftedData.Add('DesiredValue', [string]($DesiredValues[$key])) } - if (-not $Data.ContainsKey('Tenant')) + if (-not $driftedData.ContainsKey('Tenant')) { $driftedData.Add('Tenant', $TenantName) } From 20c3484e129d10ad971e80013d017d225adc3190 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 14 Feb 2024 20:59:54 -0500 Subject: [PATCH 2/5] Update M365DSCUtil.psm1 --- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 6c6baf3a4c..4599510931 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -921,6 +921,7 @@ function Test-M365DSCParameterState } if (-not $driftedData.ContainsKey('Tenant')) { + $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues $driftedData.Add('Tenant', $TenantName) } $driftedData.Add('Resource', $source.Split('_')[1]) @@ -929,16 +930,6 @@ function Test-M365DSCParameterState $EventMessage.Append(" " + $DriftedParameters.$key + "`r`n") | Out-Null } - #region Telemetry - $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues - $data.Add('Event', 'ConfigurationDrift') - - if (-not $Data.ContainsKey('Tenant')) - { - $data.Add('Tenant', $TenantName) - } - #endregion - $EventMessage.Append(" `r`n") | Out-Null $EventMessage.Append(" `r`n") | Out-Null $EventMessage.Append(" `r`n") | Out-Null From 862727ff70305d1ab15bf502c56c36684bd5d322 Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 14 Feb 2024 21:03:38 -0500 Subject: [PATCH 3/5] Update M365DSCUtil.psm1 --- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 4599510931..5f2d308de4 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -919,11 +919,8 @@ function Test-M365DSCParameterState $driftedData.Add('CurrentValue', [string]($CurrentValues[$key])) $driftedData.Add('DesiredValue', [string]($DesiredValues[$key])) } - if (-not $driftedData.ContainsKey('Tenant')) - { - $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues - $driftedData.Add('Tenant', $TenantName) - } + $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues + $driftedData.Add('Tenant', $TenantName) $driftedData.Add('Resource', $source.Split('_')[1]) Add-M365DSCTelemetryEvent -Type 'DriftInfo' -Data $driftedData #endregion From 9d212f3fc1fa9b2855afa0bf8e40f1be4dd3e94d Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Thu, 15 Feb 2024 06:53:39 -0500 Subject: [PATCH 4/5] Fixes for Telemetry --- .../MSFT_AADApplication.psm1 | 6 --- .../Modules/M365DSCTelemetryEngine.psm1 | 2 + .../Microsoft365DSC/Modules/M365DSCUtil.psm1 | 45 ++++++++++--------- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 index 0fb97b0d94..418aefd556 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADApplication/MSFT_AADApplication.psm1 @@ -806,12 +806,6 @@ function Test-TargetResource $ValuesToCheck.Remove('ObjectId') | Out-Null $ValuesToCheck.Remove('AppId') | Out-Null $ValuesToCheck.Remove('Permissions') | Out-Null - $ValuesToCheck.Remove('ApplicationId') | Out-Null - $ValuesToCheck.Remove('Credential') | Out-Null - $ValuesToCheck.Remove('TenantId') | Out-Null - $ValuesToCheck.Remove('ApplicationSecret') | Out-Null - $ValuesToCheck.Remove('CertificateThumbprint') | Out-Null - $ValuesToCheck.Remove('ManagedIdentity') | Out-Null $TestResult = Test-M365DSCParameterState -CurrentValues $CurrentValues ` -Source $($MyInvocation.MyCommand.Source) ` diff --git a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 index 040a59f077..47a4fdcedb 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 @@ -53,6 +53,7 @@ function Add-M365DSCTelemetryEvent [System.Collections.Generic.Dictionary[[System.String], [System.Double]]] $Metrics ) + $verbosepreference = 'continue' $TelemetryEnabled = [System.Environment]::GetEnvironmentVariable('M365DSCTelemetryEnabled', ` [System.EnvironmentVariableTarget]::Machine) @@ -70,6 +71,7 @@ function Add-M365DSCTelemetryEvent $Data.Add('ProjectName', $ProjectName) } + Write-Verbose -Message "Data ==== $($Data | Out-String)" if (-not $Data.ContainsKey('Tenant')) { if (-not [System.String]::IsNullOrEmpty($Data.Principal)) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 5f2d308de4..602bb22ae2 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -514,7 +514,8 @@ function Get-M365DSCTenantNameFromParameterSet [System.Collections.HashTable] $ParameterSet ) - + $VerbosePreference = 'Continue' + Write-Verbose "ParameterSet ==== $($ParameterSet | Out-String)" if ($ParameterSet.TenantId) { return $ParameterSet.TenantId @@ -898,35 +899,35 @@ function Test-M365DSCParameterState $EventMessage = [System.Text.StringBuilder]::New() $EventMessage.Append("`r`n") | Out-Null $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues + Write-Verbose -Message "Found Tenant Name: $TenantName" $EventMessage.Append(" `r`n") | Out-Null - $EventMessage.Append(" `r`n") | Out-Null + + $driftedData = [System.Collections.Generic.Dictionary[[String], [String]]]::new() + $driftedData.Add('Tenant', $TenantName) + $driftedData.Add('Resource', $source.Split('_')[1]) + $driftedData.Add('Event', 'DriftedParameter') + + # If custom App Insights is specified, allow for the current and desired values to be captured; + # ISSUE #1222 + if ($null -ne $env:M365DSCTelemetryInstrumentationKey -and ` + $env:M365DSCTelemetryInstrumentationKey -ne 'bc5aa204-0b1e-4499-a955-d6a639bdb4fa' -and ` + $env:M365DSCTelemetryInstrumentationKey -ne 'e670af5d-fd30-4407-a796-8ad30491ea7a') + { + $driftedData.Add('CurrentValues', $CurrentValues) + $driftedData.Add('DesiredValues', $DesiredValues) + } + #endregion + $telemetryDriftedParameters = '' foreach ($key in $DriftedParameters.Keys) { Write-Verbose -Message "Detected Drifted Parameter [$Source]$key" - - #region Telemetry - $driftedData = [System.Collections.Generic.Dictionary[[String], [String]]]::new() - $driftedData.Add('Event', 'DriftedParameter') - $driftedData.Add('Parameter', "[$Source]$key") - - # If custom App Insights is specified, allow for the current and desired values to be captured; - # ISSUE #1222 - if ($null -ne $env:M365DSCTelemetryInstrumentationKey -and ` - $env:M365DSCTelemetryInstrumentationKey -ne 'bc5aa204-0b1e-4499-a955-d6a639bdb4fa' -and ` - $env:M365DSCTelemetryInstrumentationKey -ne 'e670af5d-fd30-4407-a796-8ad30491ea7a') - { - $driftedData.Add('CurrentValue', [string]($CurrentValues[$key])) - $driftedData.Add('DesiredValue', [string]($DesiredValues[$key])) - } - $TenantName = Get-M365DSCTenantNameFromParameterSet -ParameterSet $DesiredValues - $driftedData.Add('Tenant', $TenantName) - $driftedData.Add('Resource', $source.Split('_')[1]) - Add-M365DSCTelemetryEvent -Type 'DriftInfo' -Data $driftedData - #endregion + $telemetryDriftedParameters += $key + "`r`n" $EventMessage.Append(" " + $DriftedParameters.$key + "`r`n") | Out-Null } + $driftedData.Add('Parameters', $telemetryDriftedParameters) + Add-M365DSCTelemetryEvent -Type 'DriftInfo' -Data $driftedData $EventMessage.Append(" `r`n") | Out-Null $EventMessage.Append(" `r`n") | Out-Null $EventMessage.Append(" `r`n") | Out-Null From f1d585ef930b486d037478110722356757bc907f Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Thu, 15 Feb 2024 06:56:03 -0500 Subject: [PATCH 5/5] Fixes Verbose --- Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 | 2 -- Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 | 2 -- 2 files changed, 4 deletions(-) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 index 47a4fdcedb..040a59f077 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCTelemetryEngine.psm1 @@ -53,7 +53,6 @@ function Add-M365DSCTelemetryEvent [System.Collections.Generic.Dictionary[[System.String], [System.Double]]] $Metrics ) - $verbosepreference = 'continue' $TelemetryEnabled = [System.Environment]::GetEnvironmentVariable('M365DSCTelemetryEnabled', ` [System.EnvironmentVariableTarget]::Machine) @@ -71,7 +70,6 @@ function Add-M365DSCTelemetryEvent $Data.Add('ProjectName', $ProjectName) } - Write-Verbose -Message "Data ==== $($Data | Out-String)" if (-not $Data.ContainsKey('Tenant')) { if (-not [System.String]::IsNullOrEmpty($Data.Principal)) diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index 602bb22ae2..1792d9d6d4 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -514,8 +514,6 @@ function Get-M365DSCTenantNameFromParameterSet [System.Collections.HashTable] $ParameterSet ) - $VerbosePreference = 'Continue' - Write-Verbose "ParameterSet ==== $($ParameterSet | Out-String)" if ($ParameterSet.TenantId) { return $ParameterSet.TenantId