DscResources/PowerPlatform/PowerPlatform.schema.psm1

# (2024-02-03 01:05:40) Generated using Microsoft365DSC v1.24.131.2
Configuration 'PowerPlatform'
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String]
        $ApplicationId,

        [Parameter(Mandatory = $true)]
        [System.String]
        $TenantId,

        [Parameter(Mandatory = $true)]
        [System.String]
        $CertificateThumbprint
    )

    Import-DscResource -ModuleName Microsoft365DSC

    foreach ($PowerAppsEnvironment in $ConfigurationData.NonNodeData.PowerPlatform.PowerAppsEnvironments)
    {
        $resourceTitle = 'PPPowerAppsEnvironment-{0}' -f $PowerAppsEnvironment.DisplayName

        $parameters = $PowerAppsEnvironment
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

        if ($parameters.ContainsKey('UniqueId'))
        {
            $parameters.Remove('UniqueId')
        }
        (Get-DscSplattedResource -ResourceName 'PPPowerAppsEnvironment' -ExecutionName $resourceTitle -Properties $parameters -NoInvoke).Invoke($parameters)
    }

    if ($ConfigurationData.NonNodeData.PowerPlatform.ContainsKey('TenantIsolationSettings'))
    {
        $resourceTitle = 'TenantIsolationSettingsDefaults'

        $parameters = $ConfigurationData.NonNodeData.PowerPlatform.TenantIsolationSettings
        $parameters.IsSingleInstance = 'Yes'
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

        if ($parameters.ContainsKey('UniqueId'))
        {
            $parameters.Remove('UniqueId')
        }
        if ($parameters.ContainsKey('Rules'))
        {
            $parameters.Rules = $parameters.Rules | ForEach-Object {
                if ($_.ContainsKey('UniqueId'))
                {
                    $_.Remove('UniqueId')
                }

                (Get-DscSplattedResource -ResourceName 'MSFT_PPTenantRule' -Properties $_ -NoInvoke).Invoke($_)
            }
        }

        if ($parameters.ContainsKey('RulesToInclude'))
        {
            $parameters.RulesToInclude = $parameters.RulesToInclude | ForEach-Object {
                if ($_.ContainsKey('UniqueId'))
                {
                    $_.Remove('UniqueId')
                }

                (Get-DscSplattedResource -ResourceName 'MSFT_PPTenantRule' -Properties $_ -NoInvoke).Invoke($_)
            }
        }

        if ($parameters.ContainsKey('RulesToExclude'))
        {
            $parameters.RulesToExclude = $parameters.RulesToExclude | ForEach-Object {
                if ($_.ContainsKey('UniqueId'))
                {
                    $_.Remove('UniqueId')
                }

                (Get-DscSplattedResource -ResourceName 'MSFT_PPTenantRule' -Properties $_ -NoInvoke).Invoke($_)
            }
        }

        (Get-DscSplattedResource -ResourceName 'PPTenantIsolationSettings' -ExecutionName $resourceTitle -Properties $parameters -NoInvoke).Invoke($parameters)
    }

    if ($ConfigurationData.NonNodeData.PowerPlatform.ContainsKey('TenantSettings'))
    {
        $resourceTitle = 'TenantSettingsDefaults'

        $parameters = $ConfigurationData.NonNodeData.PowerPlatform.TenantSettings
        $parameters.IsSingleInstance = 'Yes'
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

        if ($parameters.ContainsKey('UniqueId'))
        {
            $parameters.Remove('UniqueId')
        }
        (Get-DscSplattedResource -ResourceName 'PPTenantSettings' -ExecutionName $resourceTitle -Properties $parameters -NoInvoke).Invoke($parameters)
    }
}