Skip to content

Commit

Permalink
Merge pull request #5746 from FabienTschanz/fix/aad-export
Browse files Browse the repository at this point in the history
Fix export of AAD Cross Tenant Policies with additional cleanup
  • Loading branch information
NikCharlebois authored Feb 12, 2025
2 parents 9c09427 + 6fc37fc commit 9f6403d
Show file tree
Hide file tree
Showing 12 changed files with 11 additions and 563 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
* AADApplication
* Changing the AuthenticationBehaviors parameters to string to allow
for null values.
* AADCrossTenantAccessPolicyConfigurationDefault
* Fixes an issue with CIM class export.
* AADCrossTenantAccessPolicyConfigurationPartner
* Fixes an issue with CIM class export.
FIXES [#5711](https://github.com/microsoft/Microsoft365DSC/issues/5711)
* EXORetentionPolicyTag
* Initial release.
* EXOSmtpDaneInbound
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BCollaborationOutbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down Expand Up @@ -546,7 +546,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BDirectConnectInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down Expand Up @@ -585,7 +585,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BDirectConnectOutbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BCollaborationOutbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down Expand Up @@ -614,7 +614,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BDirectConnectInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down Expand Up @@ -653,7 +653,7 @@ function Export-TargetResource
{
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
Name = 'B2BDirectConnectOutbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1342,36 +1342,6 @@ function Get-M365DSCAzureADGroupLicenses
return $returnValue
}

function Get-M365DSCAzureADGroupLicensesAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]
$AssignedLicenses
)

$StringContent = [System.Text.StringBuilder]::new()
$StringContent.Append('@(') | Out-Null
foreach ($assignedLicense in $AssignedLicenses)
{
$StringContent.Append("MSFT_AADGroupLicense { `r`n") | Out-Null
if ($assignedLicense.DisabledPlans.Length -gt 0)
{
$StringContent.Append(" DisabledPlans = @('" + ($assignedLicense.DisabledPlans -join "','") + "')`r`n") | Out-Null
}
else
{
$StringContent.Append(" DisabledPlans = @()`r`n") | Out-Null
}
$StringContent.Append(" SkuId = '" + $assignedLicense.SkuId + "'`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}
$StringContent.Append(' )') | Out-Null
return $StringContent.ToString()
}

function Get-M365DSCCombinedLicenses
{
[CmdletBinding()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,40 +554,4 @@ function Export-TargetResource
}
}

function Get-M365DSCAADHomeRealDiscoveryPolicyDefinitionAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]
$Definitions
)

$StringContent = [System.Text.StringBuilder]::new()
$StringContent.Append('@(') | Out-Null

foreach ($definition in $Definitions)
{
$StringContent.Append("`n MSFT_AADHomeRealDiscoveryPolicyDefinition {`r`n") | Out-Null
$StringContent.Append(" PreferredDomain = '" + $definition.PreferredDomain + "'`r`n") | Out-Null
if ($null -ne $definition.AccelerateToFederatedDomain)
{
$StringContent.Append(' AccelerateToFederatedDomain = $' + $definition.AccelerateToFederatedDomain + "`r`n") | Out-Null
}
if ($null -ne $definition.AllowCloudPasswordValidation)
{
$StringContent.Append(' AllowCloudPasswordValidation = $' + $definition.AllowCloudPasswordValidation + "`r`n") | Out-Null
}
$StringContent.Append(" AlternateIdLogin = MSFT_AADHomeRealDiscoveryPolicyDefinitionAlternateIdLogin {`r`n") | Out-Null
$StringContent.Append(' Enabled = $' + $definition.AlternateIdLogin.Enabled + "`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}

$StringContent.Append(' )') | Out-Null
return $StringContent.ToString()
}


Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -690,54 +690,6 @@ function Get-M365DSCIdentityGovernanceTasks
return $taskList
}

function Get-M365DSCIdentityGovernanceTasksAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]
$Tasks
)

$StringContent = [System.Text.StringBuilder]::new()
$StringContent.Append('@(') | Out-Null

foreach ($task in $Tasks)
{
$StringContent.Append("`n MSFT_AADIdentityGovernanceTask {`r`n") | Out-Null
$StringContent.Append(" DisplayName = '" + $task.DisplayName + "'`r`n") | Out-Null
$StringContent.Append(" Description = '" + $task.Description.replace("'", "''") + "'`r`n") | Out-Null
$StringContent.Append(" Category = '" + $task.Category + "'`r`n") | Out-Null
$StringContent.Append(' IsEnabled = $' + $task.IsEnabled + "`r`n") | Out-Null
$StringContent.Append(' ExecutionSequence = ' + $task.ExecutionSequence + "`r`n") | Out-Null
$StringContent.Append(' ContinueOnError = $' + $task.ContinueOnError + "`r`n") | Out-Null
$StringContent.Append(" TaskDefinitionId = '" + $task.TaskDefinitionId + "'`r`n") | Out-Null

if ($task.Arguments.Length -gt 0)
{
$StringContent.Append(" Arguments = @(`r`n") | Out-Null
foreach ($argument in $task.Arguments)
{
$StringContent.Append(" MSFT_AADIdentityGovernanceTaskArguments {`r`n") | Out-Null
$StringContent.Append(" Name = '" + $argument.Name + "'`r`n") | Out-Null
$StringContent.Append(" Value = '" + $argument.Value + "'`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}
$StringContent.Append(" )`r`n") | Out-Null
}
else
{
$StringContent.Append(" Arguments = @()`r`n") | Out-Null
}

$StringContent.Append(" }`r`n") | Out-Null
}

$StringContent.Append(' )') | Out-Null
return $StringContent.ToString()
}

function Get-M365DSCIdentityGovernanceWorkflowExecutionConditions
{
[CmdletBinding()]
Expand Down Expand Up @@ -770,49 +722,4 @@ function Get-M365DSCIdentityGovernanceWorkflowExecutionConditions
return $executionConditionsResult
}

function Get-M365DSCIdentityGovernanceWorkflowExecutionConditionsAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param (
[Parameter(Mandatory = $true)]
[hashtable] $ExecutionConditions
)

$StringContent = [System.Text.StringBuilder]::new()

# Start of execution conditions
$StringContent.Append("MSFT_IdentityGovernanceWorkflowExecutionConditions {`r`n") | Out-Null

# Scope section
if ($null -ne $ExecutionConditions.ScopeValue)
{
$StringContent.Append(" ScopeValue = MSFT_IdentityGovernanceScope {`r`n") | Out-Null
$StringContent.Append(" Rule = '" + $ExecutionConditions.ScopeValue.Rule.replace("'", "''") + "'`r`n") | Out-Null
$StringContent.Append(" ODataType = '" + $ExecutionConditions.ScopeValue.ODataType + "'`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}

# Trigger section
if ($null -ne $ExecutionConditions.TriggerValue)
{
$StringContent.Append(" TriggerValue = MSFT_IdentityGovernanceTrigger {`r`n") | Out-Null
$StringContent.Append(' OffsetInDays = ' + $ExecutionConditions.TriggerValue.OffsetInDays + "`r`n") | Out-Null
$StringContent.Append(" TimeBasedAttribute = '" + $ExecutionConditions.TriggerValue.TimeBasedAttribute + "'`r`n") | Out-Null
$StringContent.Append(" ODataType = '" + $ExecutionConditions.TriggerValue.OdataType + "'`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}

# OdataType for executionConditions
if ($null -ne $ExecutionConditions.ODataType)
{
$StringContent.Append(" ODataType = '" + $ExecutionConditions.ODataType + "'`r`n") | Out-Null
}

# End of execution conditions
$StringContent.Append(' }') | Out-Null

return $StringContent.ToString()
}

Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -507,34 +507,5 @@ function Get-MicrosoftGraphNetworkAccessForwardingPolicyRules
return $newPolicyRules
}

function Get-MicrosoftGraphNetworkAccessForwardingPolicyRulesAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]
$PolicyRules
)

$StringContent = [System.Text.StringBuilder]::new()
$StringContent.Append('@(') | Out-Null

foreach ($rule in $PolicyRules)
{
$StringContent.Append("`n MSFT_MicrosoftGraphNetworkAccessForwardingPolicyRule {`r`n") | Out-Null
$StringContent.Append(" Name = '" + $rule.Name + "'`r`n") | Out-Null
$StringContent.Append(" ActionValue = '" + $rule.ActionValue + "'`r`n") | Out-Null
$StringContent.Append(" RuleType = '" + $rule.RuleType + "'`r`n") | Out-Null
$StringContent.Append(" Protocol = '" + $rule.Protocol + "'`r`n") | Out-Null
$StringContent.Append(' Ports = @(' + $($rule.Ports -join ', ') + ")`r`n") | Out-Null
$StringContent.Append(' Destinations = @(' + $(($rule.Destinations | ForEach-Object { "'$_'" }) -join ', ') + ")`r`n") | Out-Null
$StringContent.Append(" }`r`n") | Out-Null
}

$StringContent.Append(' )') | Out-Null
return $StringContent.ToString()
}


Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
Expand Up @@ -531,27 +531,4 @@ function Export-TargetResource
}
}

function Get-PoliciesAsString
{
[CmdletBinding()]
[OutputType([System.String])]
param(
[Parameter(Mandatory = $true)]
[System.Collections.ArrayList]
$Policies
)

$StringContent = '@('
foreach ($policy in $Policies)
{
$StringContent += "MSFT_MicrosoftGraphNetworkaccessPolicyLink {`r`n"
$StringContent += " State = '" + $policy.State + "'`r`n"
$StringContent += " PolicyLinkId = '" + $policy.PolicyLinkId + "'`r`n"
$StringContent += " Name = '" + $policy.Name + "'`r`n"
$StringContent += " }`r`n"
}
$StringContent += ' )'
return $StringContent
}

Export-ModuleMember -Function *-TargetResource
Loading

0 comments on commit 9f6403d

Please sign in to comment.