@@ -297,7 +297,6 @@ function Invoke-NinjaOneTenantSync {
297297 $Licenses = $ExtensionCache.Licenses
298298 $RawDomains = $ExtensionCache.Domains
299299 $AllConditionalAccessPolicies = $ExtensionCache.ConditionalAccess
300- Write-Output " DEBUG: AllConditionalAccessPolicies Count: $ ( $AllConditionalAccessPolicies.Count ) "
301300
302301 $CurrentSecureScore = ($SecureScore | Sort-Object createDateTime - Descending | Select-Object - First 1 )
303302 $MaxSecureScoreRank = ($SecureScoreProfiles.rank | Measure-Object - Maximum).maximum
@@ -1844,18 +1843,67 @@ function Invoke-NinjaOneTenantSync {
18441843 $StandardTemplates = Get-CIPPAzDataTableEntity @Templates | Where-Object { $_.PartitionKey -eq ' StandardsTemplateV2' }
18451844
18461845 $ParsedStandards = foreach ($Standard in $AppliedStandards ) {
1847- $Template = ($StandardTemplates | Where-Object { $_.RowKey -eq $Standard.TemplateId }).JSON | ConvertFrom-Json
1848- $StandardInfo = $StandardsDefinitions | Where-Object { ($_.name -replace ' standards.' , ' ' ) -eq $Standard.Standard }
1849- $StandardLabel = $StandardInfo.label
1850- $ParsedActions = foreach ($Action in $Standard.Settings.PSObject.Properties ) {
1851- if ($Action.Value -eq $true -and $Action.Name -in @ (' remediate' , ' report' , ' alert' )) {
1852- (Get-Culture ).TextInfo.ToTitleCase($Action.Name )
1846+ try {
1847+ $Template = ($StandardTemplates | Where-Object { $_.RowKey -eq $Standard.TemplateId }).JSON | ConvertFrom-Json
1848+ $StandardInfo = $StandardsDefinitions | Where-Object { ($_.name -replace ' standards.' , ' ' ) -eq $Standard.Standard }
1849+ $StandardLabel = $StandardInfo.label
1850+ $ParsedActions = foreach ($Action in $Standard.Settings.PSObject.Properties ) {
1851+ if ($Action.Value -eq $true -and $Action.Name -in @ (' remediate' , ' report' , ' alert' )) {
1852+ (Get-Culture ).TextInfo.ToTitleCase($Action.Name )
1853+ }
18531854 }
1854- }
1855- [PSCustomObject ]@ {
1856- Standard = $StandardLabel
1857- Template = $Template.templateName
1858- Actions = $ParsedActions -join ' , '
1855+
1856+ # Handle template-based standards that have lists of templates
1857+ if ($Standard.Standard -in @ (' IntuneTemplate' , ' ConditionalAccessTemplate' , ' GroupTemplate' )) {
1858+ # For template standards, create separate entries for each template
1859+ foreach ($Property in $Standard.Settings.PSObject.Properties ) {
1860+ if ($Property.Value -is [Array ]) {
1861+ foreach ($TemplateItem in $Property.Value ) {
1862+ $TemplateName = $null
1863+ $TemplateActions = @ ()
1864+
1865+ Write-Information " Processing Template Item: $ ( $TemplateItem | ConvertTo-Json - Depth 10 ) "
1866+ # Get template name
1867+ if ($TemplateItem.TemplateList.label ) {
1868+ $TemplateName = $TemplateItem.TemplateList.label
1869+ } elseif ($TemplateItem .' TemplateList-Tags' .label) {
1870+ $TemplateName = $TemplateItem .' TemplateList-Tags' .label
1871+ } else {
1872+ $TemplateName = $TemplateItem.TemplateList.displayName
1873+ }
1874+
1875+ # Get template-specific actions
1876+ $TemplateActions = foreach ($ItemAction in $TemplateItem.PSObject.Properties ) {
1877+ if ($ItemAction.Value -eq $true -and $ItemAction.Name -in @ (' remediate' , ' report' , ' alert' )) {
1878+ (Get-Culture ).TextInfo.ToTitleCase($ItemAction.Name )
1879+ }
1880+ }
1881+
1882+ # If no template-specific actions, use standard-level actions
1883+ if ($TemplateActions.Count -eq 0 ) {
1884+ $TemplateActions = $ParsedActions
1885+ }
1886+
1887+ if ($TemplateName ) {
1888+ [PSCustomObject ]@ {
1889+ Standard = " $StandardLabel - $TemplateName "
1890+ Template = $Template.templateName
1891+ Actions = $TemplateActions -join ' , '
1892+ }
1893+ }
1894+ }
1895+ }
1896+ }
1897+ } else {
1898+ # For non-template standards, use the original logic
1899+ [PSCustomObject ]@ {
1900+ Standard = $StandardLabel
1901+ Template = $Template.templateName
1902+ Actions = $ParsedActions -join ' , '
1903+ }
1904+ }
1905+ } catch {
1906+ Write-Information " Error processing standard $ ( $Standard ) : $_ "
18591907 }
18601908 }
18611909 $ParsedStandardsHTML = $ParsedStandards | ConvertTo-Html -As Table - Fragment
0 commit comments