.claude/worktrees/agent-a920ebd2f97275b33/manifests/collectors/Compute/VMDisk.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Compute/VMDisk.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.compute/disks'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    Preamble = @'
$ResUCount = 1
                $sub1 = $SUB | Where-Object { $_.Id -eq $1.subscriptionId }
                $data = $1.PROPERTIES
                $timecreated = $data.timeCreated
                $timecreated = [datetime]$timecreated
                $timecreated = $timecreated.ToString("yyyy-MM-dd HH:mm")
                $Retired = Foreach ($Retirement in $Retirements)
                    {
                        if ($Retirement.id -eq $1.id) { $Retirement }
                    }
                if ($Retired)
                    {
                        $RetiredFeature = foreach ($Retire in $Retired)
                            {
                                $RetiredServiceID = $Unsupported | Where-Object {$_.Id -eq $Retired.ServiceID}
                                $tmp0 = [pscustomobject]@{
                                        'RetiredFeature' = $RetiredServiceID.RetiringFeature
                                        'RetiredDate' = $RetiredServiceID.RetirementDate
                                    }
                                $tmp0
                            }
                        $RetiringFeature = if (@($RetiredFeature.RetiredFeature).count -gt 1) { $RetiredFeature.RetiredFeature | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredFeature}
                        $RetiringFeature = [string]$RetiringFeature
                        $RetiringFeature = if ($RetiringFeature -like '* ,*') { $RetiringFeature -replace ".$" }else { $RetiringFeature }
 
                        $RetiringDate = if (@($RetiredFeature.RetiredDate).count -gt 1) { $RetiredFeature.RetiredDate | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredDate}
                        $RetiringDate = [string]$RetiringDate
                        $RetiringDate = if ($RetiringDate -like '* ,*') { $RetiringDate -replace ".$" }else { $RetiringDate }
                    }
                else
                    {
                        $RetiringFeature = $null
                        $RetiringDate = $null
                    }
                $SKU = $1.SKU
                $Hibernation = if (![string]::IsNullOrEmpty($data.supportsHibernation)) { $data.supportsHibernation }else { $false }
                $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'}
'@


    AdditionalRowLoops = @()

    TagLoop = @{
        Variable = 'Tag'
        Source = '$Tags'
        Preamble = ''
    }

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Subscription'
            Expression = '$sub1.Name'
        }
        @{
            Name = 'Resource Group'
            Expression = '$1.RESOURCEGROUP'
        }
        @{
            Name = 'Disk Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'Retiring Feature'
            Expression = '$RetiringFeature'
        }
        @{
            Name = 'Retiring Date'
            Expression = '$RetiringDate'
        }
        @{
            Name = 'Disk State'
            Expression = '$data.diskState'
        }
        @{
            Name = 'Associated Resource'
            Expression = '$1.MANAGEDBY.split(''/'')[8]'
        }
        @{
            Name = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Zone'
            Expression = '[string]$1.ZONES'
        }
        @{
            Name = 'SKU'
            Expression = '$SKU.Name'
        }
        @{
            Name = 'Disk Size'
            Expression = '$data.diskSizeGB'
        }
        @{
            Name = 'Performance Tier'
            Expression = '$data.tier'
        }
        @{
            Name = 'Disk IOPS Read / Write'
            Expression = '$data.diskIOPSReadWrite'
        }
        @{
            Name = 'Disk MBps Read / Write'
            Expression = '$data.diskMBpsReadWrite'
        }
        @{
            Name = 'Public Network Access'
            Expression = '$data.publicNetworkAccess'
        }
        @{
            Name = 'Connection Type'
            Expression = '$data.networkAccessPolicy'
        }
        @{
            Name = 'Hibernation Supported'
            Expression = '$Hibernation'
        }
        @{
            Name = 'Encryption'
            Expression = '$data.encryption.type'
        }
        @{
            Name = 'OS Type'
            Expression = '$data.osType'
        }
        @{
            Name = 'Max Shares'
            Expression = '$data.maxShares'
        }
        @{
            Name = 'Data Access Auth Mode'
            Expression = '$data.dataAccessAuthMode'
        }
        @{
            Name = 'HyperV Generation'
            Expression = '$data.hyperVGeneration'
        }
        @{
            Name = 'Created Time'
            Expression = '$timecreated'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Disks'
        TableNamePrefix = 'VMDiskT_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Disk Name'
            'Retiring Feature'
            'Retiring Date'
            'Disk State'
            'Associated Resource'
            'Location'
            'Zone'
            'SKU'
            'Disk Size'
            'Performance Tier'
            'Disk IOPS Read / Write'
            'Disk MBps Read / Write'
            'Public Network Access'
            'Connection Type'
            'Hibernation Supported'
            'Encryption'
            'OS Type'
            'Max Shares'
            'Data Access Auth Mode'
            'HyperV Generation'
            'Created Time'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText Unattached -Range F:F'
            'New-ConditionalText -Range D2:D100 -ConditionalType ContainsText'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Compute/VMDisk.ps1'
}