manifests/collectors/Hybrid/ARCServers.psd1
|
# # GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Hybrid/ARCServers.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.hybridcompute/machines' ) ResourceTypeMatching = 'Grouped' AdditionalFilter = $null FilterPreamble = '' RowLoopVariable = '1' 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'} $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($data.networkprofile.networkinterfaces.ipaddresses.count -gt 1) { $IPTemp = @() $SubnetTemp = @() foreach ($IPaddresses in $data.networkprofile.networkinterfaces.ipaddresses) { $IPTemp += $IPaddresses.address $SubnetTemp += $IPaddresses.subnet.addressprefix } $IP = if ($IPTemp.count -gt 1) { $IPTemp | ForEach-Object { $_ + ' ,' } }else { $IPTemp } $IP = [string]$IP $IP = if ($IP -like '* ,*') { $IP -replace ".$" }else { $IP } $Subnet = if ($SubnetTemp.count -gt 1) { $SubnetTemp | ForEach-Object { $_ + ' ,' } }else { $SubnetTemp } $Subnet = [string]$Subnet $Subnet = if ($Subnet -like '* ,*') { $Subnet -replace ".$" }else { $Subnet } } else { $IP = $data.networkprofile.networkinterfaces.ipaddresses.address $Subnet = $data.networkprofile.networkinterfaces.ipaddresses.subnet.addressprefix } if(![string]::IsNullOrEmpty($data.laststatuschange)) { $LastStatus = $data.laststatuschange $LastStatus = [datetime]$LastStatus $LastStatus = $LastStatus.ToString("yyyy-MM-dd HH:mm") } else { $LastStatus = $null } if(![string]::IsNullOrEmpty($data.osinstalldate)) { $InstallDate = $data.osinstalldate $InstallDate = [datetime]$InstallDate $InstallDate = $InstallDate.ToString("yyyy-MM-dd HH:mm") } else { $InstallDate = $null } # Operational values are prefetched once in the collect phase. A collector # is deliberately limited to in-memory shaping: issuing ARM requests here # made output depend on the per-row reporting path and prevented a # declarative definition from being an equivalent implementation. $OperationalEnvelope = @($Resources | Where-Object { $_.TYPE -eq 'AZSC/Operational/ARCServers' -and $_.id -eq $1.id }) | Select-Object -First 1 $OperationalData = Get-AZSCSafeProperty -InputObject $OperationalEnvelope -Path 'properties' # ── Phase 17.2.6: Policies Applied ─────────────────────────────── $policyCount = 'N/A' $policyCompliant = 'N/A' $policyData = Get-AZSCSafeProperty -InputObject $OperationalData -Path 'PolicyCompliance' if ($policyData -and -not (Get-AZSCSafeProperty -InputObject $policyData -Path '__AZSCError')) { $states = @(Get-AZSCSafeProperty -InputObject $policyData -Path 'value') $policyCount = @($states).Count $nonCompliant = @($states | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'complianceState') -eq 'NonCompliant' }).Count $policyCompliant = if ($nonCompliant -eq 0) { 'Compliant' } else { "$nonCompliant NonCompliant" } } # ── Phase 17.2.7: Performance Metrics ──────────────────────────── $arcAvgCpu = 'N/A' $cpuData = Get-AZSCSafeProperty -InputObject $OperationalData -Path 'CpuMetrics' if ($cpuData -and -not (Get-AZSCSafeProperty -InputObject $cpuData -Path '__AZSCError')) { $metricValues = Get-AZSCSafeProperty -InputObject $cpuData -Path 'value' $timeSeries = @(Get-AZSCSafeProperty -InputObject $metricValues -Path 'timeseries' -Enumerate) $samples = @(Get-AZSCSafeProperty -InputObject $timeSeries -Path 'data' -Enumerate) $cpuValues = @($samples | ForEach-Object { Get-AZSCSafeProperty -InputObject $_ -Path 'average' } | Where-Object { $null -ne $_ }) if ($cpuValues) { $arcAvgCpu = [math]::Round(($cpuValues | Measure-Object -Average).Average, 1) } } # ── Phase 17.2.9: Cost / ESU Tracking ───────────────────────────── $esuEnabled = if ($data.licenseprofile.esuprofile.servertype) { $true } else { $false } $arcMonthlyCost = 'N/A' $costData = Get-AZSCSafeProperty -InputObject $OperationalData -Path 'EstimatedCost' if ($costData -and -not (Get-AZSCSafeProperty -InputObject $costData -Path '__AZSCError')) { $costRows = @(Get-AZSCSafeProperty -InputObject $costData -Path 'properties.rows') $rawArcCost = if ($costRows.Count -gt 0 -and @($costRows[0]).Count -gt 0) { @($costRows[0])[0] } else { $null } if ($null -ne $rawArcCost) { $arcMonthlyCost = [math]::Round([double]$rawArcCost, 2) } } # ── Phase 17.2.10: Hybrid Connectivity ───────────────────────────── $proxyConfigured = if ($data.agentConfiguration.proxy.url) { $true } else { $false } $privateLinkScope = if ($data.privateLinkScopeResourceId) { ($data.privateLinkScopeResourceId -split '/')[-1] } else { 'None' } $connStatus = if ($data.status) { $data.status } else { 'N/A' } '@ AdditionalRowLoops = @() TagLoop = @{ Variable = 'Tag' Source = '$Tags' Preamble = '' } Fields = @( @{ Name = 'ID' Expression = '$1.id' } @{ Name = 'Subscription' Expression = '(Get-AZSCSafeProperty -InputObject $sub1 -Path ''name'')' } @{ Name = 'Resource Group' Expression = '$1.RESOURCEGROUP' } @{ Name = 'Location' Expression = '$1.LOCATION' } @{ Name = 'Name' Expression = '$1.NAME' } @{ Name = 'Retiring Feature' Expression = '$RetiringFeature' } @{ Name = 'Retiring Date' Expression = '$RetiringDate' } @{ Name = 'Display Name' Expression = '$data.displayname' } @{ Name = 'Domain' Expression = '$data.domainname' } @{ Name = 'AD FQDN' Expression = '$data.adfqdn' } @{ Name = 'DNS FQDN' Expression = '$data.dnsfqdn' } @{ Name = 'Cloud Provider' Expression = '$data.cloudmetadata.provider' } @{ Name = 'Manufacturer' Expression = '$data.detectedproperties.manufacturer' } @{ Name = 'Model' Expression = '$data.detectedProperties.model' } @{ Name = 'Processor' Expression = '$data.detectedproperties.processornames' } @{ Name = 'Processor Count' Expression = '$data.detectedproperties.processorcount' } @{ Name = 'Logical Core Count' Expression = '$data.detectedproperties.logicalcorecount' } @{ Name = 'Memory (GB)' Expression = '$data.detectedproperties.totalphysicalmemoryingigabytes' } @{ Name = 'Serial Number' Expression = '$data.detectedproperties.serialnumber' } @{ Name = 'Asset Tag' Expression = '$data.detectedproperties.smbiosassettag' } @{ Name = 'MS SQL Server' Expression = '$data.mssqldiscovered' } @{ Name = 'Agent Version' Expression = '$data.agentversion' } @{ Name = 'Status' Expression = '$data.status' } @{ Name = 'Last Status Change' Expression = '$LastStatus' } @{ Name = 'IP Address' Expression = '$IP' } @{ Name = 'Subnet' Expression = '$Subnet' } @{ Name = 'OS Name' Expression = '$data.osName' } @{ Name = 'OS Version' Expression = '$data.osVersion' } @{ Name = 'OS Install Date' Expression = '$InstallDate' } @{ Name = 'Operating System' Expression = '$data.osSku' } @{ Name = 'License Status' Expression = '$data.licenseprofile.licensestatus' } @{ Name = 'License Channel' Expression = '$data.licenseprofile.licensechannel' } @{ Name = 'License Type' Expression = '$data.licenseprofile.esuprofile.servertype' } @{ Name = 'ESU Enabled' Expression = '$esuEnabled' } @{ Name = 'Est. Monthly Cost (USD)' Expression = '$arcMonthlyCost' } @{ Name = 'Policy Assignments' Expression = '$policyCount' } @{ Name = 'Policy Compliance' Expression = '$policyCompliant' } @{ Name = 'Avg CPU % (7d)' Expression = '$arcAvgCpu' } @{ Name = 'Proxy Configured' Expression = '$proxyConfigured' } @{ Name = 'Private Link Scope' Expression = '$privateLinkScope' } @{ Name = 'Resource U' Expression = '$ResUCount' } @{ Name = 'Tag Name' Expression = '[string]$Tag.Name' } @{ Name = 'Tag Value' Expression = '[string]$Tag.Value' } ) Export = @{ WorksheetName = 'ARC Servers' TableNamePrefix = 'ARCServer_' Columns = @( 'Subscription' 'Resource Group' 'Location' 'Name' 'Display Name' 'Domain' 'Retiring Feature' 'Retiring Date' 'AD FQDN' 'DNS FQDN' 'Cloud Provider' 'Manufacturer' 'Model' 'Processor' 'Processor Count' 'Logical Core Count' 'Memory (GB)' 'Serial Number' 'Asset Tag' 'MS SQL Server' 'Agent Version' 'Status' 'Last Status Change' 'IP Address' 'Subnet' 'OS Name' 'OS Version' 'OS Install Date' 'License Status' 'License Channel' 'License Type' 'ESU Enabled' 'Est. Monthly Cost (USD)' 'Policy Assignments' 'Policy Compliance' 'Avg CPU % (7d)' 'Proxy Configured' 'Private Link Scope' 'Resource U' ) TagColumns = @( 'Tag Name' 'Tag Value' ) TagColumnsBefore = 'Resource U' NumberFormat = '0' ConditionalText = @( 'New-ConditionalText -Range G2:G100 -ConditionalType ContainsText' ) } SourceCollector = 'Modules/Public/InventoryModules/Hybrid/ARCServers.ps1' } |