DscResources/Planner/Planner.schema.psm1

# (2024-07-04 01:15:39) Generated using Microsoft365DSC v1.24.626.1
Configuration 'Planner'
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String]
        $ApplicationId,

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

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

    Import-DscResource -ModuleName Microsoft365DSC

    foreach ($Bucket in $ConfigurationData.NonNodeData.Planner.Buckets)
    {
        $resourceTitle = 'PlannerBucket-{0}-{1}' -f $Bucket.Name,$Bucket.PlanId

        $parameters = $Bucket
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

    foreach ($Plan in $ConfigurationData.NonNodeData.Planner.Plans)
    {
        $resourceTitle = 'PlannerPlan-{0}-{1}' -f $Plan.Title,$Plan.OwnerGroup

        $parameters = $Plan
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

    foreach ($Task in $ConfigurationData.NonNodeData.Planner.Tasks)
    {
        $resourceTitle = 'PlannerTask-{0}-{1}' -f $Task.PlanId,$Task.Title

        $parameters = $Task
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

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

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

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

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