DscResources/Defender/Defender.schema.psm1

# (2024-11-14 01:27:38) Generated using Microsoft365DSC v1.24.1113.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)
    }
}