Modules/Scripts/Data/POSTGRE.ps1
<#
.Synopsis Inventory for Azure Database for Postgre .DESCRIPTION This script consolidates information for all microsoft.dbforpostgresql/servers resource provider in $Resources variable. Excel Sheet Name: POSTGRE .Link https://github.com/microsoft/ARI/Modules/Data/POSTGRE.ps1 .COMPONENT This powershell Module is part of Azure Resource Inventory (ARI) .NOTES Version: 3.1.1 First Release Date: 19th November, 2020 Authors: Claudio Merola and Renato Gregio #> <######## Default Parameters. Don't modify this ########> param($SCPath, $Sub, $Intag, $Resources, $Task , $File, $SmaResources, $TableStyle, $Unsupported) If ($Task -eq 'Processing') { $POSTGRE = $Resources | Where-Object { $_.TYPE -eq 'microsoft.dbforpostgresql/servers' } if($POSTGRE) { $tmp = @() foreach ($1 in $POSTGRE) { $ResUCount = 1 $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId } $data = $1.PROPERTIES $sku = $1.SKU $RetDate = ($Unsupported | Where-Object {$_.Id -eq 5}).RetirementDate $RetFeature = ($Unsupported | Where-Object {$_.Id -eq 5}).RetiringFeature if(!$data.privateEndpointConnections){$PVTENDP = $false}else{$PVTENDP = $data.privateEndpointConnections.Id.split("/")[8]} $Tags = if(![string]::IsNullOrEmpty($1.tags.psobject.properties)){$1.tags.psobject.properties}else{'0'} foreach ($Tag in $Tags) { $obj = @{ 'ID' = $1.id; 'Subscription' = $sub1.Name; 'Resource Group' = $1.RESOURCEGROUP; 'Name' = $1.NAME; 'Location' = $1.LOCATION; 'SKU' = $sku.name; 'SKU Family' = $sku.family; 'Tier' = $sku.tier; 'Retirement Date' = [string]$RetDate; 'Retirement Feature' = $RetFeature; 'Capacity' = $sku.capacity; 'Postgre Version' = $data.version; 'Private Endpoint' = $PVTENDP; 'Backup Retention Days' = $data.storageProfile.backupRetentionDays; 'Geo-Redundant Backup' = $data.storageProfile.geoRedundantBackup; 'Auto Grow' = $data.storageProfile.storageAutogrow; 'Storage MB' = $data.storageProfile.storageMB; 'Public Network Access' = $data.publicNetworkAccess; 'Admin Login' = $data.administratorLogin; 'Infrastructure Encryption' = $data.InfrastructureEncryption; 'Minimum TLS Version' = "$($data.minimalTlsVersion -Replace '_', '.' -Replace 'tls', 'TLS')"; 'State' = $data.userVisibleState; 'Replica Capacity' = $data.replicaCapacity; 'Replication Role' = $data.replicationRole; 'BYOK Enforcement' = $data.byokEnforcement; 'SSL Enforcement' = $data.sslEnforcement; 'Resource U' = $ResUCount; 'Tag Name' = [string]$Tag.Name; 'Tag Value' = [string]$Tag.Value } $tmp += $obj if ($ResUCount -eq 1) { $ResUCount = 0 } } } $tmp } } <######## Resource Excel Reporting Begins Here ########> Else { <######## $SmaResources.(RESOURCE FILE NAME) ##########> if ($SmaResources.POSTGRE) { $TableName = ('POSTGRETable_'+($SmaResources.POSTGRE.id | Select-Object -Unique).count) $Style = New-ExcelStyle -HorizontalAlignment Center -AutoSize -NumberFormat 0 $condtxt = @() $condtxt += New-ConditionalText FALSE -Range L:L $condtxt += New-ConditionalText FALSO -Range L:L $condtxt += New-ConditionalText Disabled -Range M:M $condtxt += New-ConditionalText Enabled -Range Q:Q $condtxt += New-ConditionalText TLSEnforcementDisabled -Range T:T $condtxt += New-ConditionalText Disabled -Range Y:Y $condtxt += New-ConditionalText - -Range J:J -ConditionalType ContainsText $Exc = New-Object System.Collections.Generic.List[System.Object] $Exc.Add('Subscription') $Exc.Add('Resource Group') $Exc.Add('Name') $Exc.Add('Location') $Exc.Add('SKU') $Exc.Add('SKU Family') $Exc.Add('Tier') $Exc.Add('Capacity') $Exc.Add('Postgre Version') $Exc.Add('Retirement Date') $Exc.Add('Retirement Feature') $Exc.Add('Private Endpoint') $Exc.Add('Backup Retention Days') $Exc.Add('Geo-Redundant Backup') $Exc.Add('Auto Grow') $Exc.Add('Storage MB') $Exc.Add('Public Network Access') $Exc.Add('Admin Login') $Exc.Add('Infrastructure Encryption') $Exc.Add('Minimum TLS Version') $Exc.Add('State') $Exc.Add('Replica Capacity') $Exc.Add('Replication Role') $Exc.Add('BYOK Enforcement') $Exc.Add('SSL Enforcement') if($InTag) { $Exc.Add('Tag Name') $Exc.Add('Tag Value') } $ExcelVar = $SmaResources.POSTGRE $ExcelVar | ForEach-Object { [PSCustomObject]$_ } | Select-Object -Unique $Exc | Export-Excel -Path $File -WorksheetName 'PostgreSQL' -AutoSize -MaxAutoSizeRows 100 -TableName $TableName -TableStyle $tableStyle -ConditionalText $condtxt -Style $Style $excel = Open-ExcelPackage -Path $File -KillExcel $null = $excel.'PostgreSQL'.Cells["J1"].AddComment("It's important to be aware of upcoming Azure services and feature retirements to understand their impact on your workloads and plan migration.", "Azure Resource Inventory") $excel.'PostgreSQL'.Cells["J1"].Hyperlink = 'https://learn.microsoft.com/en-us/azure/advisor/advisor-how-to-plan-migration-workloads-service-retirement' Close-ExcelPackage $excel } <######## Insert Column comments and documentations here following this model #########> } |