DscResources/AzureDevOps/AzureDevOps.schema.psm1

# (2024-11-14 01:27:38) Generated using Microsoft365DSC v1.24.1113.1
Configuration 'AzureDevOps'
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String]
        $ApplicationId,

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

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

    Import-DscResource -ModuleName Microsoft365DSC

    foreach ($OrganizationOwner in $ConfigurationData.NonNodeData.AzureDevOps.OrganizationOwners)
    {
        $resourceTitle = 'ADOOrganizationOwner-{0}' -f $OrganizationOwner.OrganizationName

        $parameters = $OrganizationOwner
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

    foreach ($PermissionGroup in $ConfigurationData.NonNodeData.AzureDevOps.PermissionGroups)
    {
        $resourceTitle = 'ADOPermissionGroup-{0}-{1}' -f $PermissionGroup.OrganizationName,$PermissionGroup.PrincipalName

        $parameters = $PermissionGroup
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

    foreach ($PermissionGroupSettingsItems in $ConfigurationData.NonNodeData.AzureDevOps.PermissionGroupSettingsItems)
    {
        $resourceTitle = 'ADOPermissionGroupSettings-{0}' -f $PermissionGroupSettingsItems.GroupName

        $parameters = $PermissionGroupSettingsItems
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

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

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

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

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

    foreach ($SecurityPolicy in $ConfigurationData.NonNodeData.AzureDevOps.SecurityPolicies)
    {
        $resourceTitle = 'ADOSecurityPolicy-{0}' -f $SecurityPolicy.OrganizationName

        $parameters = $SecurityPolicy
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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