manifests/collectors/Management/Backup.psd1
|
# # GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Management/Backup.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 = @( 'microsoft.recoveryservices/vaults/backuppolicies' ) ResourceTypeMatching = 'Grouped' AdditionalFilter = $null FilterPreamble = '' RowLoopVariable = '1' SetupPreamble = @' $ProtectedItems = $Resources | Where-Object {$_.TYPE -eq 'microsoft.recoveryservices/vaults/backupfabrics/protectioncontainers/protecteditems'} $BackupPolicies = $Resources | Where-Object {$_.TYPE -eq 'microsoft.recoveryservices/vaults/backuppolicies'} '@ SetupVariables = @( 'ProtectedItems' 'BackupPolicies' ) Preamble = @' $ResUCount = 1 $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId } $data = $1.PROPERTIES $Tags = if ($null -ne $1.PSObject.Properties['tags'] -and $1.tags -and @($1.tags.PSObject.Properties).Count -gt 0) { $1.tags.PSObject.Properties } else { '0' } $ProtectedObjs = $ProtectedItems | Where-Object {$_.properties.policyid -eq $1.id} $ProtectedObjs = if(![string]::IsNullOrEmpty($ProtectedObjs)){$ProtectedObjs}else{'0'} $Compression = if(![string]::IsNullOrEmpty($data.settings.iscompression)){$data.settings.iscompression}else{$false} $SQLCompression = if(![string]::IsNullOrEmpty($data.settings.issqlcompression)){$data.settings.issqlcompression}else{$false} $PolicyType = if (@($data.subprotectionpolicy.policytype).count -gt 1) { $data.subprotectionpolicy.policytype | ForEach-Object { $_ + ' ,' } }else { $data.subprotectionpolicy.policytype } $PolicyType = [string]$PolicyType $PolicyType = if ($PolicyType -like '* ,*') { $PolicyType -replace ".$" }else { $PolicyType } '@ AdditionalRowLoops = @( @{ Variable = 'ProtectedItem' # AB#6845 decision ($ProtectedItem): NO EmitNullWhenEmpty, deliberately. # $ProtectedObjs falls back to '0' when no protected item references this policy, so # the loop always runs and the policy keeps its row. # # Keeping it matters more here than almost anywhere else: a backup policy protecting # NOTHING is precisely the finding this worksheet exists to surface. Dropping it would # hide the defect the report is meant to report. The sentinel already does that job, # so the flag would be unreachable configuration. Source = '$ProtectedObjs' Preamble = @' $ProtectedItemProperties = Get-AZSCSafeProperty -InputObject $ProtectedItem -Path 'properties' $VaultId = Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path 'vaultid' $VaultResource = if(![string]::IsNullOrEmpty($VaultId)){(Get-AZSCIdSegment -Id $VaultId -Index 8)}else{''} $LastBackupTime = Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path 'lastbackuptime' if(![string]::IsNullOrEmpty($LastBackupTime)) { $LastBackup = [string](get-date($LastBackupTime)) $Currenttime = $ScoutRunTime $OldTime = get-date($LastBackupTime) $DaysSinceBKP = New-TimeSpan -Start $OldTime -End $Currenttime } else { $LastBackup = '' $DaysSinceBKP = '' } $LastRecoveryPoint = Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path 'lastrecoverypoint' $LastRecoverySecondaryPoint = Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path 'latestrecoverypointinsecondaryregion' $LastRecovery = if(![string]::IsNullOrEmpty($LastRecoveryPoint)){[string](get-date($LastRecoveryPoint))}else{''} $LastRecoverySecondary = if(![string]::IsNullOrEmpty($LastRecoverySecondaryPoint)){[string](get-date($LastRecoverySecondaryPoint))}else{$null} '@ } ) TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '$sub1.Name' } @{ Name = 'Resource Group' Expression = '$1.RESOURCEGROUP' } @{ Name = 'Backup Policy Name' Expression = '$1.NAME' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Datasource Type' Expression = '$data.workloadtype' } @{ Name = 'Protected Items Count' Expression = '$data.protecteditemscount' } @{ Name = 'Backup Compression' Expression = '$Compression' } @{ Name = 'SQL Compression' Expression = '$SQLCompression' } @{ Name = 'Policy Type' Expression = '$PolicyType' } @{ Name = 'Protected Item Type' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''backupmanagementtype''' } @{ Name = 'Protected Item' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''friendlyname''' } @{ Name = 'Vault' Expression = '$VaultResource' } @{ Name = 'Retention Period' Expression = '[string](Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''configuredmaximumretention'')' } @{ Name = 'Backup Frequency' Expression = '[string](Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''configuredrpgenerationfrequency'')' } @{ Name = 'Health Status' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''healthstatus''' } @{ Name = 'Protection Status' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''protectionstatus''' } @{ Name = 'Archive Enabled' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''isarchiveenabled''' } @{ Name = 'Last Backup Status' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''lastbackupstatus''' } @{ Name = 'Last Backup Time' Expression = '$LastBackup' } @{ Name = 'Days Since Last Backup' Expression = 'if ($DaysSinceBKP -is [TimeSpan]) { $DaysSinceBKP.Days } else { $null }' } @{ Name = 'Last Recovery Point' Expression = '$LastRecovery' } @{ Name = 'Latest Recovery Point (Secondary Region)' Expression = '$LastRecoverySecondary' } @{ Name = 'Protection State' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''protectionstate''' } @{ Name = 'Protection State (Secondary Region)' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''protectionstateinsecondaryregion''' } @{ Name = 'Soft Delete Retention Period' Expression = 'Get-AZSCSafeProperty -InputObject $ProtectedItemProperties -Path ''softdeleteretentionperiod''' } @{ Name = 'Resource U' Expression = '$ResUCount' } @{ Name = 'Tag Name' Expression = '[string]$Tag.Name' } @{ Name = 'Tag Value' Expression = '[string]$Tag.Value' } ) Export = @{ WorksheetName = 'Backup' TableNamePrefix = 'BackupTable_' Columns = @( 'Subscription' 'Resource Group' 'Backup Policy Name' 'Location' 'Datasource Type' 'Protected Items Count' 'Backup Compression' 'SQL Compression' 'Policy Type' 'Protected Item Type' 'Protected Item' 'Vault' 'Retention Period' 'Backup Frequency' 'Health Status' 'Protection Status' 'Archive Enabled' 'Last Backup Status' 'Last Backup Time' 'Days Since Last Backup' 'Last Recovery Point' 'Latest Recovery Point (Secondary Region)' 'Protection State' 'Protection State (Secondary Region)' 'Soft Delete Retention Period' 'Resource U' ) TagColumns = @( 'Tag Name' 'Tag Value' ) TagColumnsBefore = 'Resource U' NumberFormat = '0' ConditionalText = @( 'New-ConditionalText 0 -Range F:F' 'New-ConditionalText failed -Range O:O' 'New-ConditionalText incomplete -Range R:R' 'New-ConditionalText Unhealthy -Range P:P' 'New-ConditionalText notprotected -Range W:W' 'New-ConditionalText 0 -Range Y:Y' 'New-ConditionalText -ConditionalType GreaterThan 7 -Range T:T' ) } SourceCollector = 'Modules/Public/InventoryModules/Management/Backup.ps1' } |