manifests/collectors/Compute/AVD.psd1
|
# # GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Compute/AVD.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.desktopvirtualization/hostpools' ) ResourceTypeMatching = 'Grouped' AdditionalFilter = $null FilterPreamble = '' RowLoopVariable = '1' SetupPreamble = @' $VM = $Resources | Where-Object {$_.TYPE -eq 'microsoft.compute/virtualmachines'} $AVD = $Resources | Where-Object { $_.TYPE -eq 'microsoft.desktopvirtualization/hostpools' } $Hosts = $Resources | Where-Object { $_.TYPE -eq 'microsoft.desktopvirtualization/hostpools/sessionhosts' } '@ SetupVariables = @( 'VM' 'AVD' 'Hosts' ) Preamble = @' $ResUCount = 1 $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId } $data = $1.PROPERTIES $sessionhosts = @() foreach ($h in $Hosts){ $n = $h.ID -split '/sessionhosts/' if ($n[0] -eq $1.id ) { $sessionhosts += $h } } $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 } if ($1.ZONES) { $Zones = $1.ZONES }else { $Zones = 'Not Configured' } $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'} '@ AdditionalRowLoops = @( @{ Variable = '2' Source = '$sessionhosts' # AB#6845: a host pool with no session hosts is a real and interesting state -- newly # created, drained for maintenance, or scaled to zero -- and without this the pool # produced no row and disappeared from the AVD worksheet altogether. The pool is the # resource being inventoried; the session hosts are detail. EmitNullWhenEmpty = $true Preamble = @' $domain = if([string]::IsNullOrEmpty($2.name)){''}else{([string]$2.name).replace(((([string]$2.name).split("."))[0]),'')} $sessionHostResourceId = Get-AZSCSafeProperty -InputObject $2 -Path 'properties.resourceId' $vmsessionhosts = $VM | Where-Object { $_.ID -eq $sessionHostResourceId } '@ } ) TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '$sub1.Name' } @{ Name = 'Resource Group' Expression = '$1.RESOURCEGROUP' } @{ Name = 'Hostpool Name' Expression = '$1.NAME' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Retiring Feature' Expression = '$RetiringFeature' } @{ Name = 'Retiring Date' Expression = '$RetiringDate' } @{ Name = 'Zone' Expression = '$Zones' } @{ Name = 'HostPool Type' Expression = '$data.hostPoolType' } @{ Name = 'LoadBalancer' Expression = '$data.loadBalancerType' } @{ Name = 'maxSessionLimit' Expression = '$data.maxSessionLimit' } @{ Name = 'preferred AppGroup' Expression = '$data.preferredAppGroupType' } @{ Name = 'AVD Agent Version' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.agentVersion'')' } @{ Name = 'Last Assigned User' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.assignedUser'')' } @{ Name = 'Allow New Session' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.allowNewSession'')' } @{ Name = 'Update Status' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.updateState'')' } @{ Name = 'Hostname' Expression = '(Get-AZSCSafeProperty -InputObject $vmsessionhosts -Path ''name'')' } @{ Name = 'Domain' Expression = '$domain' } @{ Name = 'VM Size' Expression = '(Get-AZSCSafeProperty -InputObject $vmsessionhosts -Path ''properties.hardwareProfile.vmsize'')' } @{ Name = 'OS Type' Expression = '(Get-AZSCSafeProperty -InputObject $vmsessionhosts -Path ''properties.storageProfile.osdisk.ostype'')' } @{ Name = 'VM Disk Type' Expression = '(Get-AZSCSafeProperty -InputObject $vmsessionhosts -Path ''properties.storageProfile.osdisk.managedDisk.storageAccountType'')' } @{ Name = 'Sessions' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.sessions'')' } @{ Name = 'Host Status' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.status'')' } @{ Name = 'OS Version' Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''properties.osVersion'')' } @{ Name = 'Resource U' Expression = '$ResUCount' } @{ Name = 'Tag Name' Expression = '[string]$Tag.Name' } @{ Name = 'Tag Value' Expression = '[string]$Tag.Value' } ) Export = @{ WorksheetName = 'AVD' TableNamePrefix = 'AVD_' Columns = @( 'Subscription' 'Resource Group' 'Hostpool Name' 'Location' 'Retiring Feature' 'Retiring Date' 'Zone' 'HostPool Type' 'LoadBalancer' 'maxSessionLimit' 'preferred AppGroup' 'AVD Agent Version' 'Last Assigned User' 'Allow New Session' 'Update Status' 'Hostname' 'Domain' 'VM Size' 'OS Type' 'VM Disk Type' 'Sessions' 'Host Status' 'OS Version' 'Resource U' ) TagColumns = @( 'Tag Name' 'Tag Value' ) TagColumnsBefore = 'Resource U' NumberFormat = '0' ConditionalText = @( 'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText' 'New-ConditionalText "Not Configured" -Range G:G' ) } SourceCollector = 'Modules/Public/InventoryModules/Compute/AVD.ps1' } |