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 # AB#5671: an EMPTY $sub1 (subscription outside the requested scope) is not $null, # so `.Name` on it throws; and `timeCreated` is absent on older disk API versions, # where [datetime]$null then produced a bogus 0001-01-01 anyway. $sub1 = $SUB | Where-Object { $_.Id -eq $1.subscriptionId } # The else arm is $null, NOT '': with StrictMode off $sub1.Name on an unmatched ($null) # $sub1 evaluated to $null, and the ~110 collectors that still read $sub1.Name directly # emit $null here. '' was a silent behaviour change -- the declarative equivalence proof # caught it on 11 collectors, and it would have been invisible on the rest (AB#5659). $SubscriptionName = if ($sub1) { @($sub1)[0].Name } else { $null } $data = $1.PROPERTIES $timecreated = Get-AZSCSafeProperty -InputObject $data -Path 'timeCreated' $timecreated = if ($timecreated) { ([datetime]$timecreated).ToString("yyyy-MM-dd HH:mm") } else { '' } $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 = Get-AZSCSafeProperty -InputObject $1 -Path 'SKU' # Every `properties` field below is OPTIONAL in the disk API response: an unattached # standard disk omits maxShares, tier, dataAccessAuthMode, networkAccessPolicy and # osType outright, and `MANAGEDBY` is absent on any disk not currently attached -- # where the historic `.split('/')[8]` also indexed past the end of a short id. $Hibernation = $data | Get-AZSCSafeProperty -Path 'supportsHibernation' $Hibernation = if (![string]::IsNullOrEmpty($Hibernation)) { $Hibernation }else { $false } $ManagedBySegments = @() $ManagedBy = Get-AZSCSafeProperty -InputObject $1 -Path 'MANAGEDBY' if (![string]::IsNullOrEmpty($ManagedBy)) { $ManagedBySegments = @(([string]$ManagedBy).split('/')) } $AssociatedResource = if ($ManagedBySegments.Count -gt 8) { $ManagedBySegments[8] } else { $null } $RowTags = Get-AZSCSafeProperty -InputObject $1 -Path 'tags' $TagProps = if ($null -ne $RowTags) { $RowTags.psobject.properties } else { $null } # '0' was a sentinel to run the loop once for an untagged resource; `'0'.Name` # throws under StrictMode, and an empty tag object emits the identical row. $Tags = if(![string]::IsNullOrEmpty($TagProps)){$TagProps}else{[pscustomobject]@{ Name = $null; Value = $null }} '@ AdditionalRowLoops = @() TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '$SubscriptionName' } @{ 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 = '(Get-AZSCSafeProperty -InputObject $data -Path ''diskState'')' } @{ Name = 'Associated Resource' Expression = '$AssociatedResource' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Zone' Expression = '[string](Get-AZSCSafeProperty -InputObject $1 -Path ''ZONES'')' } @{ Name = 'SKU' Expression = '(Get-AZSCSafeProperty -InputObject $SKU -Path ''Name'')' } @{ Name = 'Disk Size' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''diskSizeGB'')' } @{ Name = 'Performance Tier' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''tier'')' } @{ Name = 'Disk IOPS Read / Write' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''diskIOPSReadWrite'')' } @{ Name = 'Disk MBps Read / Write' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''diskMBpsReadWrite'')' } @{ Name = 'Public Network Access' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''publicNetworkAccess'')' } @{ Name = 'Connection Type' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''networkAccessPolicy'')' } @{ Name = 'Hibernation Supported' Expression = '$Hibernation' } @{ Name = 'Encryption' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''encryption.type'')' } @{ Name = 'OS Type' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''osType'')' } @{ Name = 'Max Shares' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''maxShares'')' } @{ Name = 'Data Access Auth Mode' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''dataAccessAuthMode'')' } @{ Name = 'HyperV Generation' Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''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' } |