Skip to content

Update-M365DSCAuthenticationConfiguration

Description

This function parses an existing Microsoft365DSC configuration file, removes the authentication parameters from every resource instance it contains and replaces them with the ones matching the requested connection mode. The updated resource instances are converted back into DSC syntax and written to the file specified by the DestinationFile parameter.

On top of the resource instances located inside the 'Node localhost' section, the header of the configuration file is updated as well. The PSCredential parameters and the initialization of the $CredsCredential and $CredsCertificatePassword variables are added or removed based on the requested connection mode, as is the initialization of the $OrganizationName variable.

The values used by the updated configuration are not written to the associated ConfigurationData file, which therefore needs to be updated manually before the configuration can be applied. The entries that need to be present are listed in the output of the function.

Output

This function does not generate any output.

Parameters

Parameter Required DataType Default Value Allowed Values Description
SourceFile True String Specifies the path of the configuration file to parse and update the authentication parameters in.
DestinationFile True String Specifies the fully qualified path of the file the updated configuration is written to.
ConnectionMode True String ServicePrincipalWithThumbprint, ServicePrincipalWithSecret, ServicePrincipalWithPath, CredentialsWithTenantId, CredentialsWithApplicationId, Credentials, ManagedIdentity, AccessTokens Specifies the authentication mode the configuration should be updated to. Accepted values are ServicePrincipalWithThumbprint, ServicePrincipalWithSecret, ServicePrincipalWithPath, CredentialsWithTenantId, CredentialsWithApplicationId, Credentials, ManagedIdentity and AccessTokens.

Examples

-------------------------- EXAMPLE 1 --------------------------

Update-M365DSCAuthenticationConfiguration -SourceFile 'C:\DSC\M365TenantConfig.ps1' -DestinationFile 'C:\DSC\M365TenantConfig-MSI.ps1' -ConnectionMode 'ManagedIdentity'