Skip to content

Commit

Permalink
Merge pull request #5676 from NikCharlebois/Refactored-Export
Browse files Browse the repository at this point in the history
Centralized export logic for CimInstances
  • Loading branch information
NikCharlebois authored Jan 27, 2025
2 parents 94f9df4 + 6a66a81 commit 2b836d6
Show file tree
Hide file tree
Showing 14 changed files with 754 additions and 93 deletions.
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,29 @@

# UNRELEASED

* AADAdminConsentRequestPolicy
* Refactored the export to use a common CIMInstance function.
* AADCrossTenantAccessPolicyConfigurationDefault
* Refactored the export to use a common CIMInstance function.
* AADCrossTenantAccessPolicyConfigurationPartner
* Refactored the export to use a common CIMInstance function.
* AADGroup
* Refactored the export to use a common CIMInstance function.
* AADHomeRealmDiscoveryPolicy
* Refactored the export to use a common CIMInstance function.
* AADIdentityGovernanceLifecycleWorkflow
* Refactored the export to use a common CIMInstance function.
* AADNetworkAccessForwardingPolicy
* Refactored the export to use a common CIMInstance function.
* AADNetworkAccessForwardingProfile
* Refactored the export to use a common CIMInstance function.
* AADRemoteNetwork
* Refactored the export to use a common CIMInstance function.
* AADRoleAssignmentScheduleRequest
* Refactored the export to use a common CIMInstance function.
* AADRoleEligibilityScheduleRequest
* Fixed overall logic to prevent errors complaining about existing permissions.
* Refactored the export to use a common CIMInstance function.
* FabricAdminTenantSettings
* Fix titles that have a zero length whitespace character.
* IntuneAppProtectionPolicyAndroid
Expand All @@ -27,6 +48,10 @@
* O365SearchAndIntelligenceConfigurations
* Added support for Meeting Insights settings.
* Added support for Service Principal authentication.
* TeamsEmergencyCallRoutingPolicy
* Refactored the export to use a common CIMInstance function.
* TeamsTenantDialPlan
* Refactored the export to use a common CIMInstance function.

# 1.25.122.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -468,20 +468,38 @@ function Export-TargetResource
$Results = Update-M365DSCExportAuthenticationResults -ConnectionMode $ConnectionMode `
-Results $Results

if ($Results.Reviewers.Count -gt 0)
if ($null -ne $Results.Reviewers)
{
$Results.Reviewers = Get-M365DSCAzureADAAdminConsentPolicyReviewerAsString $Results.Reviewers
$complexMapping = @(
@{
Name = 'Reviewers'
CimInstanceName = 'AADAdminConsentRequestPolicyReviewer'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.Reviewers `
-CIMInstanceName 'AADAdminConsentRequestPolicyReviewer' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.Reviewers = $complexTypeStringResult
}
else
{
$Results.Remove('Reviewers') | Out-Null
}
}

$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
-ConnectionMode $ConnectionMode `
-ModulePath $PSScriptRoot `
-Results $Results `
-Credential $Credential

if ($Results.Reviewers)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Reviewers' -IsCIMArray:$true
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'Reviewers' -IsCIMArray:$True
}
$dscContent += $currentDSCBlock
Save-M365DSCPartialExport -Content $currentDSCBlock `
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,23 +472,182 @@ function Export-TargetResource

if ($null -ne $Results.B2BCollaborationInbound)
{
$Results.B2BCollaborationInbound = Get-M365DSCAADCrossTenantAccessPolicyB2BSettingAsString -Setting $Results.B2BCollaborationInbound
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
@{
Name = 'Applications'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'UsersAndGroups'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'Targets'
CimInstanceName = 'AADCrossTenantAccessPolicyTarget'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.B2BCollaborationInbound `
-CIMInstanceName 'AADCrossTenantAccessPolicyB2BSetting' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.B2BCollaborationInbound = $complexTypeStringResult
}
else
{
$Results.Remove('B2BCollaborationInbound') | Out-Null
}
}

if ($null -ne $Results.B2BCollaborationOutbound)
{
$Results.B2BCollaborationOutbound = Get-M365DSCAADCrossTenantAccessPolicyB2BSettingAsString -Setting $Results.B2BCollaborationOutbound
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
@{
Name = 'Applications'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'UsersAndGroups'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'Targets'
CimInstanceName = 'AADCrossTenantAccessPolicyTarget'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.B2BCollaborationOutbound `
-CIMInstanceName 'AADCrossTenantAccessPolicyB2BSetting' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.B2BCollaborationOutbound = $complexTypeStringResult
}
else
{
$Results.Remove('B2BCollaborationOutbound') | Out-Null
}
}

if ($null -ne $Results.B2BDirectConnectInbound)
{
$Results.B2BDirectConnectInbound = Get-M365DSCAADCrossTenantAccessPolicyB2BSettingAsString -Setting $Results.B2BDirectConnectInbound
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
@{
Name = 'Applications'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'UsersAndGroups'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'Targets'
CimInstanceName = 'AADCrossTenantAccessPolicyTarget'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.B2BDirectConnectInbound `
-CIMInstanceName 'AADCrossTenantAccessPolicyB2BSetting' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.B2BDirectConnectInbound = $complexTypeStringResult
}
else
{
$Results.Remove('B2BDirectConnectInbound') | Out-Null
}
}

if ($null -ne $Results.B2BDirectConnectOutbound)
{
$Results.B2BDirectConnectOutbound = Get-M365DSCAADCrossTenantAccessPolicyB2BSettingAsString -Setting $Results.B2BDirectConnectOutbound
$complexMapping = @(
@{
Name = 'B2BCollaborationInbound'
CimInstanceName = 'AADCrossTenantAccessPolicyB2BSetting'
IsRequired = $False
},
@{
Name = 'Applications'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'UsersAndGroups'
CimInstanceName = 'AADCrossTenantAccessPolicyTargetConfiguration'
IsRequired = $False
},
@{
Name = 'Targets'
CimInstanceName = 'AADCrossTenantAccessPolicyTarget'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.B2BDirectConnectOutbound `
-CIMInstanceName 'AADCrossTenantAccessPolicyB2BSetting' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.B2BDirectConnectOutbound = $complexTypeStringResult
}
else
{
$Results.Remove('B2BDirectConnectOutbound') | Out-Null
}
}

if ($null -ne $Results.InboundTrust)
{
$Results.InboundTrust = Get-M365DSCAADCrossTenantAccessPolicyInboundTrustAsString -Setting $Results.InboundTrust
$complexMapping = @(
@{
Name = 'InboundTrust'
CimInstanceName = 'AADCrossTenantAccessPolicyInboundTrust'
IsRequired = $False
}
)
$complexTypeStringResult = Get-M365DSCDRGComplexTypeToString `
-ComplexObject $Results.InboundTrust `
-CIMInstanceName 'AADCrossTenantAccessPolicyInboundTrust' `
-ComplexTypeMapping $complexMapping

if (-Not [String]::IsNullOrWhiteSpace($complexTypeStringResult))
{
$Results.InboundTrust = $complexTypeStringResult
}
else
{
$Results.Remove('InboundTrust') | Out-Null
}
}

$currentDSCBlock = Get-M365DSCExportContentForResource -ResourceName $ResourceName `
Expand All @@ -497,30 +656,25 @@ function Export-TargetResource
-Results $Results `
-Credential $Credential

if ($null -ne $Results.B2BCollaborationInbound)
if ($Results.B2BCollaborationInbound)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'B2BCollaborationInbound'
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'B2BCollaborationInbound' -IsCIMArray:$True
}
if ($null -ne $Results.B2BCollaborationOutbound)
if ($Results.B2BCollaborationOutbound)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'B2BCollaborationOutbound'
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'B2BCollaborationOutbound' -IsCIMArray:$True
}
if ($null -ne $Results.B2BDirectConnectInbound)
if ($Results.B2BDirectConnectInbound)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'B2BDirectConnectInbound'
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'B2BDirectConnectInbound' -IsCIMArray:$True
}
if ($null -ne $Results.B2BDirectConnectOutbound)
if ($Results.B2BDirectConnectOutbound)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'B2BDirectConnectOutbound'
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'B2BDirectConnectOutbound' -IsCIMArray:$True
}
if ($null -ne $Results.InboundTrust)
if ($Results.InboundTrust)
{
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock `
-ParameterName 'InboundTrust'
$currentDSCBlock = Convert-DSCStringParamToVariable -DSCBlock $currentDSCBlock -ParameterName 'InboundTrust' -IsCIMArray:$True
}

# Fix OrganizationName variable in CIMInstance
Expand Down
Loading

0 comments on commit 2b836d6

Please sign in to comment.