question

EnterpriseArchitect avatar image
0 Votes"
EnterpriseArchitect asked EnterpriseArchitect commented

Using Azure PowerShell how can I export the Firewalls and virtual networks settings to .CSV file?

Using Azure PowerShell how can I export the Firewalls and virtual networks settings to .CSV file?


116598-image.png


azure-virtual-network
image.png (6.9 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

suvasara-MSFT avatar image
1 Vote"
suvasara-MSFT answered EnterpriseArchitect commented

@EnterpriseArchitect, Apologies for delay in response. Here is the PS script to export the Firewalls and Virtual network rules accordingly,

For Firewall Rules,

 $Firewall = Get-AzSqlServerFirewallRule -ResourceGroupName "RG-Name" -ServerName "Server-Name"
 $FirewallOutput = $Firewall | ForEach-Object {
     [PSCustomObject]@{
         "ResourceGroupName" = $_.ResourceGroupName
         "ServerName" = $_.ServerName
         "StartIpAddress" = $_.StartIpAddress
         "EndIpAddress" = $_.EndIpAddress
         "FirewallRuleName" = $_.FirewallRuleName
     }
 }
    
 $FirewallOutput | export-csv /home/subhash/data.csv -delimiter ";" -force -notypeinformation

For Virtual Network rules,

Get-AzSqlServerVirtualNetworkRule -ResourceGroupName "RG-Name" -ServerName "Server-Name"

Copy the above the script script and replace the attributes accordingly to export them to CSV files.



Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.




· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @suvasara-MSFT thank you for the update.
May I know how can I get the detailed FW rule that is mentioned in the FirewallRuleName column?

118521-image.png


0 Votes 0 ·
image.png (9.6 KiB)

Because when I execute the below line:

Get-AzSqlServer | Get-AzSqlServerVirtualNetworkRule | ogv

it is still asking for ServerName and ResourceGroupName.

0 Votes 0 ·

This script also not showing up the result in a table format:

 & {
     ForEach ($AzSQLServer in $(Get-AzSqlServer) ) {
         Get-AzSqlServerVirtualNetworkRule -ServerName $AzSQLServer.ServerName -ResourceGroupName $AzSQLServer.ResourceGroupName
     }
 } | ft -AutoSize
0 Votes 0 ·