Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into DRG-cleanup-microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
William-Francillette committed Jul 9, 2023
2 parents 18e85fd + 6e0b1dc commit d057e15
Show file tree
Hide file tree
Showing 44 changed files with 1,766 additions and 647 deletions.
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
# Change log for Microsoft365DSC

# UNRELEASED
# 1.23.705.1

* EXOAddressList
* Improved export performance.
* EXOCASMailboxSettings
* Improved export performance.
* EXODataClassification
* Improved export performance.
* EXODistributionGroup
* Improved export performance.
* EXOGroupSettings
* Improved export performance.
* EXOMailboxPlan
* Support comparing instances without the GUID in the name.
FIXES [#3314](https://github.com/microsoft/Microsoft365DSC/issues/3314)
* EXOManagementRole
* Improved export performance.
* EXOManagementRoleAssignment
* Improved export performance.
* EXORoleGroup
* Improved export performance.
* DEPENDENCIES
* Updated all Microsoft.Graph modules to version 2.0.0.
* Updated all MSCloudLoginAssistant modules to version 1.0.116.
* MISC
* Updated QA tests to dynamically retrieve the permission list.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,8 +1074,10 @@ function Export-TargetResource
}
if ($null -ne $Results.Members)
{
$currentDSCBlock = $currentDSCBlock.Replace("`",`"`r`n", "")
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Members' -IsCIMArray $true
$currentDSCBlock = $currentDSCBlock.Replace(",`r`n", '').Replace("`");`r`n", ");`r`n")
$currentDSCBlock = $currentDSCBlock.Replace("Members = @(`"", "Members = @(")
$currentDSCBlock = $currentDSCBlock.Replace("`$OrganizationName'", "' + `$OrganizationName")
}
$dscContent += $currentDSCBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,20 @@ function Get-TargetResource
}
catch
{
New-M365DSCLogEntry -Message 'Error retrieving data:' `
-Exception $_ `
-Source $($MyInvocation.MyCommand.Source) `
-TenantId $TenantId `
-Credential $Credential
if ($Script:ExportMode)
{
throw $_
}
else
{
New-M365DSCLogEntry -Message 'Error retrieving data:' `
-Exception $_ `
-Source $($MyInvocation.MyCommand.Source) `
-TenantId $TenantId `
-Credential $Credential

return $nullReturn
return $nullReturn
}
}
}

Expand Down Expand Up @@ -808,7 +815,7 @@ function Export-TargetResource

$ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' `
-InboundParameters $PSBoundParameters

$dscContent = [System.Text.StringBuilder]::new()
$i = 1
Write-Host "`r`n" -NoNewline
Expand All @@ -830,33 +837,43 @@ function Export-TargetResource
Credential = $Credential
Managedidentity = $ManagedIdentity.IsPresent
}
$Results = Get-TargetResource @Params

if ($Results.Ensure -eq 'Present')
try
{
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results
if ($Results.Permissions.Count -gt 0)
$Results = Get-TargetResource @Params
if ($Results.Ensure -eq 'Present')
{
$Results.Permissions = Get-M365DSCAzureADAppPermissionsAsString $Results.Permissions
}
$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results
if ($Results.Permissions.Count -gt 0)
{
$Results.Permissions = Get-M365DSCAzureADAppPermissionsAsString $Results.Permissions
}
$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential

if ($null -ne $Results.Permissions)
if ($null -ne $Results.Permissions)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'Permissions'
}

$dscContent.Append($currentDSCBlock) | Out-Null
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
Write-Host $Global:M365DSCEmojiGreenCheckMark
$i++
}
}
catch
{
if ($_.Exception.Message -like "*Multiple AAD Apps with the Displayname*")
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'Permissions'
Write-Host "`r`n $($Global:M365DSCEmojiYellowCircle)" -NoNewline
Write-Host " Multiple app instances wth name {$($AADApp.DisplayName)} were found. We will skip exporting these instances."
}

$dscContent.Append($currentDSCBlock) | Out-Null
Save-M365DSCPartialExport -Content $currentDSCBlock `
-FileName $Global:PartialExportFileName
Write-Host $Global:M365DSCEmojiGreenCheckMark
$i++
}
}
return $dscContent.ToString()
Expand Down Expand Up @@ -920,7 +937,7 @@ function Get-M365DSCAzureADAppPermissions
$appServicePrincipal = Get-MgServicePrincipal -Filter "AppId eq '$($app.AppId)'" -All:$true
if ($null -ne $appServicePrincipal)
{
$oAuth2grant = Get-MgOauth2PermissionGrant -Filter "ClientId eq '$($appServicePrincipal.Id)'"
$oAuth2grant = Get-MgBetaOauth2PermissionGrant -Filter "ClientId eq '$($appServicePrincipal.Id)'"
if ($null -ne $oAuth2grant)
{
$scopes = $oAuth2grant.Scope.Split(' ')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,8 @@ function Export-TargetResource
if ($Results.CertificateUserBindings)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'CertificateUserBindings' -IsCIMArray:$True
$currentDSCBlock = $currentDSCBlock.Replace('CertificateUserBindings = @("', 'CertificateUserBindings = @(')
$currentDSCBlock = $currentDSCBlock.Replace(" `",`"`r`n", '')
}
if ($Results.ExcludeTargets)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function Get-TargetResource

try
{
$Policy = Get-MgPolicyAuthorizationPolicy -ErrorAction Stop
$Policy = Get-MgBetaPolicyAuthorizationPolicy -ErrorAction Stop
}
catch
{
Expand Down Expand Up @@ -350,7 +350,7 @@ function Set-TargetResource
try
{
Write-Verbose -Message "Updating existing authorization policy with values: $(Convert-M365DscHashtableToString -Hashtable $UpdateParameters)"
$response = Update-MgPolicyAuthorizationPolicy @updateParameters -ErrorAction Stop
$response = Update-MgBetaPolicyAuthorizationPolicy @updateParameters -ErrorAction Stop
}
catch
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function Get-TargetResource
$nullResult = $PSBoundParameters
$nullResult.Ensure = 'Absent'

$getValue = Get-MgPolicyCrossTenantAccessPolicy -ErrorAction SilentlyContinue
$getValue = Get-MgBetaPolicyCrossTenantAccessPolicy -ErrorAction SilentlyContinue

if ($null -eq $getValue)
{
Expand Down Expand Up @@ -182,7 +182,7 @@ function Set-TargetResource
{
$UpdateParams.Add("AllowedCloudEndpoints", $AllowedCloudEndpoints)
}
Update-MgPolicyCrossTenantAccessPolicy -BodyParameter $UpdateParams
Update-MgBetaPolicyCrossTenantAccessPolicy -BodyParameter $UpdateParams
}
elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function Get-TargetResource
$nullResult = $PSBoundParameters
$nullResult.Ensure = 'Absent'

$getValue = Get-MgPolicyCrossTenantAccessPolicyDefault -ErrorAction SilentlyContinue
$getValue = Get-MgBetaPolicyCrossTenantAccessPolicyDefault -ErrorAction SilentlyContinue

if ($null -eq $getValue)
{
Expand Down Expand Up @@ -250,7 +250,7 @@ function Set-TargetResource
if ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present')
{
Write-Verbose -Message "Updating Cross Tenant Access Policy Configuration Default"
Update-MgPolicyCrossTenantAccessPolicyDefault @OperationParams
Update-MgBetaPolicyCrossTenantAccessPolicyDefault @OperationParams
}
elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present')
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function Get-TargetResource
$nullResult = $PSBoundParameters
$nullResult.Ensure = 'Absent'

$getValue = Get-MgPolicyCrossTenantAccessPolicyPartner -CrossTenantAccessPolicyConfigurationPartnerTenantId $PartnerTenantId `
$getValue = Get-MgBetaPolicyCrossTenantAccessPolicyPartner -CrossTenantAccessPolicyConfigurationPartnerTenantId $PartnerTenantId `
-ErrorAction SilentlyContinue

if ($null -eq $getValue)
Expand Down Expand Up @@ -251,19 +251,19 @@ function Set-TargetResource
Write-Verbose -Message (Convert-M365DscHashtableToString -Hashtable $OperationParams)
$OperationParams.Add('TenantId', $PartnerTenantId)
$OperationParams.Remove('PartnerTenantId') | Out-Null
New-MgPolicyCrossTenantAccessPolicyPartner @OperationParams
New-MgBetaPolicyCrossTenantAccessPolicyPartner @OperationParams
}
elseif ($Ensure -eq 'Present' -and $currentInstance.Ensure -eq 'Present')
{
Write-Verbose -Message "Updating Cross Tenant Access Policy Configuration Partner entry with TenantId {$PartnerTenantId}"
$OperationParams.Add('-CrossTenantAccessPolicyConfigurationPartnerTenantId', $PartnerTenantId)
$OperationParams.Remove('PartnerTenantId') | Out-Null
Update-MgPolicyCrossTenantAccessPolicyPartner @OperationParams
Update-MgBetaPolicyCrossTenantAccessPolicyPartner @OperationParams
}
elseif ($Ensure -eq 'Absent' -and $currentInstance.Ensure -eq 'Present')
{
Write-Verbose -Message "Removing Cross Tenant Access Policy Configuration Partner entry with TenantId {$PartnerTenantId}"
Remove-MgPolicyCrossTenantAccessPolicyPartner -CrossTenantAccessPolicyConfigurationPartnerTenantId $PartnerTenantId
Remove-MgBetaPolicyCrossTenantAccessPolicyPartner -CrossTenantAccessPolicyConfigurationPartnerTenantId $PartnerTenantId
}
}

Expand Down Expand Up @@ -440,7 +440,7 @@ function Export-TargetResource

try
{
[array] $getValue = Get-MgPolicyCrossTenantAccessPolicyPartner -ErrorAction Stop
[array] $getValue = Get-MgBetaPolicyCrossTenantAccessPolicyPartner -ErrorAction Stop

$i = 1
$dscContent = ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function Get-TargetResource
$formattedAccessReviewSettings = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $getValue.AccessReviewSettings
if($null -ne $formattedAccessReviewSettings)
{
$formattedAccessReviewSettings.remove('additionalProperties')
$formattedAccessReviewSettings.remove('additionalProperties') | Out-Null
}
if ($null -ne $formattedAccessReviewSettings.Reviewers -and $formattedAccessReviewSettings.Reviewers.count -gt 0 )
{
Expand All @@ -138,7 +138,7 @@ function Get-TargetResource
$setting.add('odataType', $setting.AdditionalProperties.'@odata.type')
if (-not [String]::isNullOrEmpty($setting.AdditionalProperties.id))
{
$user = Get-MgUser -UserId $setting.AdditionalProperties.Id -ErrorAction SilentlyContinue
$user = Get-MgUser -UserId $setting.AdditionalProperties.id -ErrorAction SilentlyContinue
if ($null -ne $user)
{
$setting.add('Id', $user.UserPrincipalName)
Expand All @@ -148,7 +148,7 @@ function Get-TargetResource
{
$setting.add('ManagerLevel', $setting.AdditionalProperties.managerLevel)
}
$setting.remove('additionalProperties')
$setting.remove('additionalProperties') | Out-Null
}
}
#endregion
Expand All @@ -157,7 +157,7 @@ function Get-TargetResource
$formattedRequestApprovalSettings = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $getValue.RequestApprovalSettings
if ($null -ne $formattedRequestApprovalSettings)
{
$formattedRequestApprovalSettings.remove('additionalProperties')
$formattedRequestApprovalSettings.remove('additionalProperties') | Out-Null
}
if ($null -ne $formattedRequestApprovalSettings.approvalStages -and $formattedRequestApprovalSettings.approvalStages.count -gt 0 )
{
Expand All @@ -176,7 +176,7 @@ function Get-TargetResource
{
$setting.add('ManagerLevel', $setting.AdditionalProperties.managerLevel)
}
$setting.remove('additionalProperties')
$setting.remove('additionalProperties') | Out-Null
}
}

Expand All @@ -193,10 +193,10 @@ function Get-TargetResource
{
$setting.add('ManagerLevel', $setting.AdditionalProperties.managerLevel)
}
$setting.remove('additionalProperties')
$setting.remove('additionalProperties') | Out-Null
}
}
$approvalStage.remove('additionalProperties')
$approvalStage.remove('additionalProperties') | Out-Null
}
}
#endregion
Expand All @@ -205,7 +205,7 @@ function Get-TargetResource
$formattedRequestorSettings = Get-M365DSCDRGComplexTypeToHashtable -ComplexObject $getValue.RequestorSettings
if ($null -ne $formattedRequestorSettings)
{
$formattedRequestorSettings.remove('additionalProperties')
$formattedRequestorSettings.remove('additionalProperties') | Out-Null
}
if ($null -ne $formattedRequestorSettings.allowedRequestors -and $formattedRequestorSettings.allowedRequestors.count -gt 0 )
{
Expand All @@ -217,7 +217,7 @@ function Get-TargetResource
}
if(-not [String]::isNullOrEmpty($setting.AdditionalProperties.id))
{
$user = Get-MgUser -UserId $setting.AdditionalProperties.Id -ErrorAction SilentlyContinue
$user = Get-MgUser -UserId $setting.AdditionalProperties.id -ErrorAction SilentlyContinue
if ($null -ne $user)
{
$setting.add('Id', $user.UserPrincipalName)
Expand All @@ -227,7 +227,7 @@ function Get-TargetResource
{
$setting.add('ManagerLevel', $setting.AdditionalProperties.managerLevel)
}
$setting.remove('additionalProperties')
$setting.remove('additionalProperties') | Out-Null
}
}
#endregion
Expand All @@ -243,11 +243,11 @@ function Get-TargetResource
if ($null -ne $question.Text)
{
$question.add('QuestionText', $question.Text)
$question.remove('Text')
$question.QuestionText.remove('additionalProperties')
$question.remove('Text') | Out-Null
$question.QuestionText.remove('additionalProperties') | Out-Null
foreach ($localizedText in $question.QuestionText.localizedTexts)
{
$localizedText.remove('additionalProperties')
$localizedText.remove('additionalProperties') | Out-Null
}
}
if ($null -ne $question.AdditionalProperties.isSingleLineQuestion)
Expand All @@ -262,7 +262,7 @@ function Get-TargetResource
{
$question.add('AllowsMultipleSelection', $question.AdditionalProperties.allowsMultipleSelection)
}
$question.remove('additionalProperties')
$question.remove('additionalProperties') | Out-Null
}
#endregion

Expand Down
Loading

0 comments on commit d057e15

Please sign in to comment.