manifests/collectors/Identity/ServicePrincipals.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Identity/ServicePrincipals.ps1 (AB#5660).
# Field expressions are copied verbatim from the original collector and evaluate in an
# equivalent scope -- see docs/design/decisions/declarative-collectors.md.
# Review before trusting; regenerate rather than hand-patch if the source collector changes.
#
@{
    ResourceTypes = @(
        'entra/serviceprincipals'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
            $data = Get-AZSCSafeProperty -InputObject $1 -Path 'properties'
 
            # Get nearest key credential expiry
            $keyExpiry = $null
            if (Get-AZSCSafeProperty -InputObject $data -Path 'keyCredentials') {
                $keyExpiry = Get-AZSCSafeProperty -InputObject $data -Path 'keyCredentials' -Enumerate | ForEach-Object { Get-AZSCSafeProperty -InputObject $_ -Path 'endDateTime' } | Where-Object { $_ } | Sort-Object | Select-Object -First 1
            }
 
            # Get nearest password credential expiry
            $passwordExpiry = $null
            if (Get-AZSCSafeProperty -InputObject $data -Path 'passwordCredentials') {
                $passwordExpiry = Get-AZSCSafeProperty -InputObject $data -Path 'passwordCredentials' -Enumerate | ForEach-Object { Get-AZSCSafeProperty -InputObject $_ -Path 'endDateTime' } | Where-Object { $_ } | Sort-Object | Select-Object -First 1
            }
 
            $tagList = ''
            if (Get-AZSCSafeProperty -InputObject $data -Path 'tags') {
                $tagList = ((Get-AZSCSafeProperty -InputObject $data -Path 'tags' -Enumerate) -join ', ')
            }
'@


    AdditionalRowLoops = @()

    TagLoop = $null

    Fields = @(
        @{
            Name = 'ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $1 -Path ''id'''
        }
        @{
            Name = 'Tenant ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $1 -Path ''tenantId'''
        }
        @{
            Name = 'Display Name'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''displayName'''
        }
        @{
            Name = 'Application ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''appId'''
        }
        @{
            Name = 'Service Principal Type'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''servicePrincipalType'''
        }
        @{
            Name = 'Account Enabled'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''accountEnabled'''
        }
        @{
            Name = 'App Owner Organization ID'
            Expression = 'Get-AZSCSafeProperty -InputObject $data -Path ''appOwnerOrganizationId'''
        }
        @{
            Name = 'Key Credential Expiry'
            Expression = '$keyExpiry'
        }
        @{
            Name = 'Password Credential Expiry'
            Expression = '$passwordExpiry'
        }
        @{
            Name = 'Tags'
            Expression = '$tagList'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
    )

    Export = @{
        WorksheetName = 'Service Principals'
        TableNamePrefix = 'SPsTable_'
        Columns = @(
            'Display Name'
            'Application ID'
            'Service Principal Type'
            'Account Enabled'
            'App Owner Organization ID'
            'Key Credential Expiry'
            'Password Credential Expiry'
            'Tags'
            'Resource U'
        )
        TagColumns = @()
        TagColumnsBefore = $null
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText False -Range F:F'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Identity/ServicePrincipals.ps1'
}