From 7788013a5fe06ab2153bf751b8707e2c6deba47a Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 14 Feb 2024 20:53:56 -0500 Subject: [PATCH 1/6] 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/6] 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/6] 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 ca1e6330994d4e1f78059670a872e71674e74e91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andi=20Kr=C3=BCger?= <15608729+andikrueger@users.noreply.github.com> Date: Thu, 15 Feb 2024 11:33:27 +0100 Subject: [PATCH 4/6] fixed some documentation typos --- .../get-started/authentication-and-permissions.md | 13 +++++++++---- .../user-guide/get-started/monitoring-drifts.md | 1 + .../user-guide/get-started/powershell7-support.md | 14 +++++++------- docs/docs/user-guide/get-started/prerequisites.md | 8 ++++++++ .../get-started/snapshot-of-existing-tenant.md | 15 ++++++++++++++- 5 files changed, 39 insertions(+), 12 deletions(-) diff --git a/docs/docs/user-guide/get-started/authentication-and-permissions.md b/docs/docs/user-guide/get-started/authentication-and-permissions.md index e61a750122..77ce686d01 100644 --- a/docs/docs/user-guide/get-started/authentication-and-permissions.md +++ b/docs/docs/user-guide/get-started/authentication-and-permissions.md @@ -54,7 +54,7 @@ In order to authenticate to Power Apps using a Service Principal (Certificate Th Additionally, to be able to authenticate using a Certificate Thumbprint, the underlying Power Apps PowerShell module used by Microsoft365DSC requires the certificate's private key (.pfx) to be registered under the current user's certificate store at Cert:\CurrentUser\My\. Omitting to register the private key will result in Microsoft365DSC throwing the following error when trying to authenticate to the Power Platform: -``` +```powershell Get-Item: Cannot find path 'Cert:\CurrentUser\My\****************************************' because it does not exist. ``` @@ -174,14 +174,16 @@ SharePoint Online uses the legacy ACS model to authenticate using an Application 3. In the App domain box, type in www..com. 4. Leave the **Redirect URL** box empty. 5. In the **Permission request XML** box, put in the following XML: -``` + +```powershell ``` + 6. Click on the **Create** button. Register a new app for SharePoint Online. -7. On the next screen, click on the ** Trust It** button to complete the registration process. +7. On the next screen, click on the **Trust It** button to complete the registration process. Register a new app for SharePoint Online. You should now be able to connect to SharePoint Online using an Application Secret. @@ -217,10 +219,11 @@ If you want to leverage Service Principal Authentication (using an App Registrat PowerShell Script to create a service principal -``` powershell +```powershell $App = Get-MgApplication -Filter "DisplayName eq 'MySCApp'" New-ServicePrincipal -AppId $App.AppId -ServiceId $App.Id -DisplayName "SC-SPN" ``` +
  • Grant the eDiscovery Manager role to your new Service Principal:

    @@ -232,6 +235,7 @@ New-ServicePrincipal -AppId $App.AppId -ServiceId $App.Id -DisplayName "SC-SPN" $SPN = Get-ServicePrincipal -Identity "SC-SPN" Add-RoleGroupMember -Identity eDiscoveryManager -Member $SPN.ObjectId ``` +
  • @@ -245,6 +249,7 @@ Add-RoleGroupMember -Identity eDiscoveryManager -Member $SPN.ObjectId $SPN = Get-ServicePrincipal -Identity "SC-SPN" Add-eDiscoveryCaseAdmin -User $SPN.Name ``` +

  • Grant your app registration the Compliance Administrator role:

    diff --git a/docs/docs/user-guide/get-started/monitoring-drifts.md b/docs/docs/user-guide/get-started/monitoring-drifts.md index 7a120f1bd1..5c76dbc8c0 100644 --- a/docs/docs/user-guide/get-started/monitoring-drifts.md +++ b/docs/docs/user-guide/get-started/monitoring-drifts.md @@ -1,6 +1,7 @@ Once a configuration has been applied to a Microsoft 365 tenant using Microsoft365DSC, the local system will perform regular checks to analyze the configuration of the remote tenant against what its desired state should be and detect any configuration drifts. This feature comes from PowerShell DSC out-of-the-box and is not something specific to Microsoft365DSC. By default the DSC engine on the system where the configuration was applied from will check for configuration drifts every 15 minutes. ## Microsoft365DSC Event log + If a drift in configuration is detected, Microsoft365DSC will log it in Event Viewer on the machine. Detected drifts will get logged under the **M365DSC** log journal in Event Viewer. Microsoft365DSC provide very detailed entries in event viewer that help you identify exactly in what component a drift was detected as well as what property was detected to have drifted.
    diff --git a/docs/docs/user-guide/get-started/powershell7-support.md b/docs/docs/user-guide/get-started/powershell7-support.md index 5b699bac5b..cb869406b4 100644 --- a/docs/docs/user-guide/get-started/powershell7-support.md +++ b/docs/docs/user-guide/get-started/powershell7-support.md @@ -4,12 +4,12 @@ While Microsoft365DSC supports running PowerShell 7+, there are a few things tha Microsoft365DSC currently requires dependencies to be installed under the C:\Program Files\WindowsPowerShell\Modules folders. Having the dependencies installed anywhere else can cause issues loading modules. The recommendation here is to use PowerShell 5.1 to install the Module using: -``` +```powershell Install-Module Microsoft365DSC -Force Update-M365DSCModule ``` -Then flip to PowerShell 7+ once the prerequesite modules are properly installed under C:\Program Files\WindowsPowerShell\Modules. +Then flip to PowerShell 7+ once the prerequisite modules are properly installed under C:\Program Files\WindowsPowerShell\Modules. ## Common Issues When the Modules are Not in the Right Folder @@ -17,7 +17,7 @@ Then flip to PowerShell 7+ once the prerequesite modules are properly installed The module that is ensuring the proper encoding of the exported DSC content relies on the Get-DscResource cmdlet to cache information about the resources' properties and is a way to improve performance. If the Microsoft365DSC module is not located under the Windows PowerShell folder, every instance extracted by the Export process will throw the following error: -``` +```powershell WARNING: There are no modules present in the system with the given module specification. ``` @@ -25,15 +25,15 @@ To solve this, make sure the Microsoft365DSC is properly installed under C:\Prog **Issues loading the PnP.PowerShell Module** -The PnP.PowerShell module, which is currently being used by the SharePoint Online and OndeDrive for Business workloads needs to be loaded using Windows PowerShell. In PowerShell 7+, this is done by running the **Import-Module** cmdlet using the **-UseWindowsPowerShell** switch, and requires the modules to be located under C:\Program Files\WindowsPowerShell. In order for Microsoft365DSC to work for SharePoint Online and OneDrive for Business with PowerShell 7, you need to make sure that the PnP.PowerShell module is located under C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell. This can be achieved by either manually moving the module to that location, or by using PowerShell 5.1 to install it using the following line: +The PnP.PowerShell module, which is currently being used by the SharePoint Online and OneDrive for Business workloads needs to be loaded using Windows PowerShell. In PowerShell 7+, this is done by running the **Import-Module** cmdlet using the **-UseWindowsPowerShell** switch, and requires the modules to be located under C:\Program Files\WindowsPowerShell. In order for Microsoft365DSC to work for SharePoint Online and OneDrive for Business with PowerShell 7, you need to make sure that the PnP.PowerShell module is located under C:\Program Files\WindowsPowerShell\Modules\PnP.PowerShell. This can be achieved by either manually moving the module to that location, or by using PowerShell 5.1 to install it using the following line: -``` +```powershell Install-Module PnP.PowerShell -Force -Scope AllUsers ``` The reason why this module needs to be loaded using WindowsPowerShell is because it tries to load its own version of the System.IdentityModel.Tokens assembly, which conflicts with the one used by the Microsoft.Graph.Authentication module. Microsoft365DSC often requires both modules to be loaded at the same time, which causes a conflict. By using the -UseWindowsPowerShell switch, we load the PnP.PowerShell module into its own separate runspace, which avoids the assembly conflicts. Having the PnP module installed under any path other than the Windows PowerShell one can result in one of the issues listed below: -``` +```powershell Exception: Powershell 7+ was detected. We need to load the PnP.PowerShell module using the -UseWindowsPowerShell switch which requires the module to be installed under C:\Program Files\WindowsPowerShell\Modules. You can either move the module to that location or use PowerShell 5.1 to install the modules using 'Install-Module Pnp.PowerShell -Force -Scope AllUsers'. @@ -45,6 +45,6 @@ Connect-PnPOnline: Could not load file or assembly 'System.IdentityModel.Tokens. Starting with PowerShell 7.2, the core Desired State Configuration module (PSdesiredStateConfiguration) has been decoupled from the core PowerShell build and now need to be installed separately. In a PowerShell 7+ console, you can install the module by running the command: -``` +```powershell Install-Module PSDesiredStateConfiguration -Force ``` diff --git a/docs/docs/user-guide/get-started/prerequisites.md b/docs/docs/user-guide/get-started/prerequisites.md index dbb7bc3282..0ff30b9b23 100644 --- a/docs/docs/user-guide/get-started/prerequisites.md +++ b/docs/docs/user-guide/get-started/prerequisites.md @@ -1,18 +1,23 @@ ## Technical requirements + For Microsoft365DSC to function, you need to arrange the following components: ### PowerShell version + Microsoft365DSC is supported for PowerShell version 5.1 and 7.3+. For additional details on how to leverage it with PowerShell 7, please refer to our [PowerShell 7+ Guide for Microsoft365DSC](https://microsoft365dsc.com/user-guide/get-started/powershell7-support/). ### Tooling + To get the best experience running Microsoft365DSC cmdlets, it is recommended that you use the Windows Terminal. All screenshots provided in this article are using the Windows Terminal. This tool allows you to quickly switch between PowerShell versions and provide better support for icons and symbols that are used throughout Microsoft365DSC’s experience. ### Permissions + In order to connect to Microsoft 365, you need to make sure you have valid credentials (user **or** application credentials) with the correct permissions to the Microsoft 365 service. Microsoft365DSC offers several methods of authentication, depending on the used resources. Unfortunately, we are depending on the supported authentication methods used by the various PowerShell modules that are used. Make sure you review the [Authentication and Permissions](../authentication-and-permissions) article for more information on the available authentication methods and how to configure all required permissions. ## Experience and skills + Before you start using Microsoft365DSC, it is important that you also have the proper experience and skills on administering Microsoft 365. Microsoft365DSC is a powerful solution that can greatly streamline Microsoft 365 administration. But with great power comes great responsibility: **If you don't know what exactly you are doing, using Microsoft365DSC you can also cause some serious damage.** @@ -34,16 +39,19 @@ Additionally it can be helpful, depending on the planned use of Microsoft365DSC, You can review the following training resources and certifications, for learning more about the above topics: #### PowerShell Desired State Configuration + - Get started with Desired State Configuration for Windows - Separating configuration and environment data - Video series: "Getting Started with PowerShell Desired State Configuration" #### Microsoft 365 Administration + - About the Microsoft 365 admin center - Overview of the Microsoft 365 admin center - About admin roles - Video: Get an overview of the Microsoft 365 admin center #### Recommended Certification + - Microsoft 365 Certified: Fundamentals (MS-900) - Microsoft 365 Certified: Enterprise Administrator Expert (MS-100 & MS-101) diff --git a/docs/docs/user-guide/get-started/snapshot-of-existing-tenant.md b/docs/docs/user-guide/get-started/snapshot-of-existing-tenant.md index 49c28a70cb..317bd62603 100644 --- a/docs/docs/user-guide/get-started/snapshot-of-existing-tenant.md +++ b/docs/docs/user-guide/get-started/snapshot-of-existing-tenant.md @@ -6,13 +6,13 @@ In previous versions of the module, simply running the above cmdlet would automa Initiating the snapshot process via the **Export-M365DSCConfiguration** cmdlet will begin by authenticating against all required workloads. The first thing it will do is compile a list of all components it is about to capture and figure out what workload they are part of. Then it will automatically authenticated against each one using the authentication parameters provided. ## Web Based User Interface + While the default process has changed with recent versions of the module, you can still use a newly revamped, web-based User Interface to help you build the PowerShell command to execute based on the components you wish to capture. To launch this new web interface, simply use the **-LaunchWebUI** switch when calling the Export-M365DSCConfiguration cmdlet. This will automatically launch a new web browser interface and navigate you to https://export.microsoft365dsc.com
    ![Screenshot of the Microsoft365DSC Export site](../../Images/ExportGUI.png)
    The Microsoft365DSC Export generator
    - On the web page, simply select the components you want to export and click on the **Generate** button at the top right. This will open a new prompt that will allow you to copy the PowerShell command you need to run to capture a snapshot of the selected components via Microsoft365DSC. Simply copy this command and paste it in your PowerShell console to initiate the capture process.
    @@ -21,6 +21,7 @@ On the web page, simply select the components you want to export and click on th
    ## Unattended Capture + As mentioned above, Microsoft365DSC now defaults to an unattended capture process when running the **Export-M365DSCConfiguration** cmdlet. To quickly get started, simply open a new PowerShell console and run the cmdlet. By default, if you don’t provide any additional parameters to the cmdlet, it will try to use credentials to authenticate against the various workloads. In the case where no additional authentication parameters are provided, Microsoft365DSC will prompt you for credentials and will use those credentials to authenticate throughout the capture process.
    @@ -46,6 +47,7 @@ Export-M365DSCConfiguration -Credential $creds
    ### Running An Export Using Service Principal + The same process applies if you are trying to authenticate using a Service Principal. In this case you would need to pass in the ApplicationID and TenantID parameter and decide whether to use an Application Secret or a Certificate Thumbprint.
    @@ -87,9 +89,11 @@ It is also important to note, the resulting file will always contain random GUID
    ## Available Parameters + The Microsoft365DSC tenant configuration snapshot feature offers several options you can use to better control the output capture. This section provides an overview of each additional parameter that is available for the **Export-M365DSCConfiguration** cmdlet and how they can be used during the capture process ### LaunchWebUI + As mentioned above, the moment this switch is present when calling the **Export-M365DSCConfiguration** cmdlet it will launch new browser window and navigate to the export user interface at https://export.microsoft365dsc.com. ```PowerShell @@ -97,6 +101,7 @@ Export-M365DSCConfiguration -LaunchWebUI ``` ### Components + This parameter accepts an array containing the names of the components you want to capture as part of your snapshot. Omitting this parameter will default the capture process to capture all components that are part of the default components list (see parameter **Mode**).
    @@ -105,6 +110,7 @@ This parameter accepts an array containing the names of the components you want
    ### ConfigurationName + This parameter allows you to specify how the DSC configuration object, inside of the exported configuration file will be named.
    @@ -115,6 +121,7 @@ This parameter allows you to specify how the DSC configuration object, inside of Omitting to specify this parameter will result in the configuration object to be named as the file’s name (e.g. M365TenantConfig). ### FileName + This allows you to specify how you wish the resulting file to be named. Specify the name of the file, including the extension (e.g. .ps1).
    @@ -125,6 +132,7 @@ This allows you to specify how you wish the resulting file to be named. Specify Omitting to specify this parameter will name the resulting file as M365TenantConfig.ps1 ### Filters + This allows you to specify a filter at the resource level to reduce the overall instances that are being extracted. As an example, if you are only interested in extracting Azure AD Groups that have their display name start with the word 'Microsoft', you could specify the following filters: ``` @@ -139,6 +147,7 @@ $Filters = @{
    ### GenerateInfo + This parameter allows users to specify whether or not comments should be added as part of the exported file to provide additional information about the various types of components captured.
    ![Example of specifying whether to generate additional information](../../Images/ExportGenerateInfo.png) @@ -146,6 +155,7 @@ This parameter allows users to specify whether or not comments should be added a
    ### MaxProcesses + There are a few components inside of Microsoft365DSC for which parallelism has been implemented as part of their snapshot process to improve speed. This parameter allows user to specify how many parallel threads should be created during the capture process. Components leveraging parallelism are: SPOPropertyBag, SPOUserProfileProperty and TeamsUser. The specified value for this parameter has to be between **1** and **100**. Instances of the components will be equally divided amongst the various threads.
    @@ -161,6 +171,7 @@ There are a few components inside of Microsoft365DSC for which parallelism has b While there are advantages to implementing multithreading for the snapshot process, there are many disadvantages as well such as not being able to properly view ongoing progress inside threads and added complexity to the design of the resources. After weighting in the pros can cons of implementing this approach across all components to speed up the entire capture process, we’ve opted to keep the design of the resources simpler (no use parallelism) for maintenance purposes and to ensure users have a consistent way of view progress during the snapshot process. ### Mode + This parameter allows users to specify what set of components they wish to capture as part of their snapshot process. By default, Microsoft365DSC will exclude some components from the capture process either because these are likely to take a very long time to export (e.g. SPOPropertyBag) or that they are more related to data than actual configuration settings (e.g. Planner Tasks, SPOUserProfileProperty, etc.). Available modes are: - Lite @@ -178,6 +189,7 @@ To keep track of what resources are available in what mode, Microsoft365DSC defi This means that the **Lite** extraction mode will contain all resources with the exception of those listed in Default and Full. The **Default** mode will include all resources from the Lite mode, plus the SPOApp and SPOSiteDesign components, and **Full** will include every resource available in the project. ### Path + This parameter allows you to specify the location where the resulting file will be stored. Omitting to specify this parameter will prompt the user to provide the destination path at the end of the capture process.
    @@ -186,6 +198,7 @@ This parameter allows you to specify the location where the resulting file will
    ### Workloads + This parameter accepts an array containing the names of various workloads you wish to capture the components for as part of your snapshot process. Users need to specify the acronym of the workloads, which can be any of: - **AAD** – Azure Active Directory From 9d212f3fc1fa9b2855afa0bf8e40f1be4dd3e94d Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Thu, 15 Feb 2024 06:53:39 -0500 Subject: [PATCH 5/6] 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 6/6] 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