DscResources/Defender/Defender.schema.psm1

# (2024-12-13 01:43:39) Generated using Microsoft365DSC v1.24.1211.1
Configuration 'Defender'
{
    param
    (
        [Parameter(Mandatory = $true)]
        [System.String]
        $ApplicationId,

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

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

    Import-DscResource -ModuleName Microsoft365DSC

    foreach ($DeviceAuthenticatedScanDefinition in $ConfigurationData.NonNodeData.Defender.DeviceAuthenticatedScanDefinitions)
    {
        $resourceTitle = 'DefenderDeviceAuthenticatedScanDefinition-{0}' -f $DeviceAuthenticatedScanDefinition.Name

        $parameters = $DeviceAuthenticatedScanDefinition
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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

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

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

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

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

    foreach ($SubscriptionPlan in $ConfigurationData.NonNodeData.Defender.SubscriptionPlans)
    {
        $resourceTitle = 'DefenderSubscriptionPlan-{0}-{1}' -f $SubscriptionPlan.SubscriptionName,$SubscriptionPlan.PlanName

        $parameters = $SubscriptionPlan
        $parameters.ApplicationId = $ApplicationId
        $parameters.TenantId = $TenantId
        $parameters.CertificateThumbprint = $CertificateThumbprint

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