Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Centralized export logic for CimInstances #5676

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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