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(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$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' Source = '$ProtectedObjs' Preamble = @' $VaultResource = if(![string]::IsNullOrEmpty($ProtectedItem.properties.vaultid)){$ProtectedItem.properties.vaultid.split('/')[8]}else{''} if(![string]::IsNullOrEmpty($ProtectedItem.properties.lastbackuptime)) { $LastBackup = [string](get-date($ProtectedItem.properties.lastbackuptime)) $Currenttime = get-date $OldTime = get-date($ProtectedItem.properties.lastbackuptime) $DaysSinceBKP = New-TimeSpan -Start $OldTime -End $Currenttime } else { $LastBackup = '' $DaysSinceBKP = '' } $LastRecovery = if(![string]::IsNullOrEmpty($ProtectedItem.properties.lastrecoverypoint)){[string](get-date($ProtectedItem.properties.lastrecoverypoint))}else{''} $LastRecoverySecondary = if(![string]::IsNullOrEmpty($ProtectedItem.properties.latestrecoverypointinsecondaryregion)){[string](get-date($ProtectedItem.properties.latestrecoverypointinsecondaryregion))} '@ } ) 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 = '$ProtectedItem.properties.backupmanagementtype' } @{ Name = 'Protected Item' Expression = '$ProtectedItem.properties.friendlyname' } @{ Name = 'Vault' Expression = '$VaultResource' } @{ Name = 'Retention Period' Expression = '[string]$ProtectedItem.properties.configuredmaximumretention' } @{ Name = 'Backup Frequency' Expression = '[string]$ProtectedItem.properties.configuredrpgenerationfrequency' } @{ Name = 'Health Status' Expression = '$ProtectedItem.properties.healthstatus' } @{ Name = 'Protection Status' Expression = '$ProtectedItem.properties.protectionstatus' } @{ Name = 'Archive Enabled' Expression = '$ProtectedItem.properties.isarchiveenabled' } @{ Name = 'Last Backup Status' Expression = '$ProtectedItem.properties.lastbackupstatus' } @{ Name = 'Last Backup Time' Expression = '$LastBackup' } @{ Name = 'Days Since Last Backup' Expression = '$DaysSinceBKP.Days' } @{ Name = 'Last Recovery Point' Expression = '$LastRecovery' } @{ Name = 'Latest Recovery Point (Secondary Region)' Expression = '$LastRecoverySecondary' } @{ Name = 'Protection State' Expression = '$ProtectedItem.properties.protectionstate' } @{ Name = 'Protection State (Secondary Region)' Expression = '$ProtectedItem.properties.protectionstateinsecondaryregion' } @{ Name = 'Soft Delete Retention Period' Expression = '$ProtectedItem.properties.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' } |