Posts

Export or Backup Azure Virtual Networks or Subnet information into CSV using PowerShell

 There may be times when you  want to get a report that contains information of all VNETS along with their subnets and address prefixes. You might have question, how to export or backup Azure VNET or subnets information into CSV.  This script will export Azure Virtual Network information along with subnets and address prefixes of all Active subscriptions into a CSV. $outputfinal=@() foreach ( $Subscription in $(Get-AzSubscription| Where-Object {$_.State -ne "Disabled"}) ) { Select-AzSubscription -SubscriptionId $Subscription.SubscriptionId $nets=Get-AzVirtualNetwork foreach ($net in $nets) { $snets=$net.Subnets foreach ($snet in $snets) { $outputtemp = "" | SELECT  VNET,VNET_AddressSpace,VNET_Location,ResourceGroup,Subnet_Name,Subnet_AddressPrefix $outputtemp.VNET=$net.Name $outputtemp.VNET_AddressSpace=$net.AddressSpace.AddressPrefixes.trim('{}') $outputtemp.VNET_Location=$net.Location $outputtemp.ResourceGroup=$net.ResourceGroupName $outputtemp.Subnet_Name

Automating a PowerShell Script using Azure Automation Account

So you have have created a PowerShell script to run a job quickly, but now you want to automate that PowerShell Script at a scheduled interval. For this you can use Azure Automation account where you can add you PowerShell script as a runbook and schedule that runbook at a desired time interval. In addition to the script that you have created, you also need to add some additional lines to make Automation account use a connection. Also note that if your script is performing some action (read or write) on any other subscription where the automation account is created, then you'll have to grant Automation Account's Runas account, the access of other subscriptions (You can refer the Microsoft article here. ) So, this is the PowerShell Script that you can use in your Automation Account Runbook.  $connectionName = "AzureRunAsConnection" try {     # Get the connection "AzureRunAsConnection "     $servicePrincipalConnection=Get-AutomationConnection -Name $connection

Export or Backup Azure Network Security Groups into CSV using PowerShell

There could be many use cases where you may want to export Network Security Groups into CSV. You might have question, how to export or backup Azure Network Security Groups into CSV. Here is the PowerShell script that you can use to export Azure Network Security Groups into CSV using PowerShell script. This script will export Network Security Group along with rules of all Active subscriptions into a CSV. $outputfinal=@() foreach ( $Subscription in $(Get-AzSubscription| Where-Object {$_.State -ne "Disabled"}) ) { Select-AzSubscription -SubscriptionId $Subscription.SubscriptionId $nsgs=Get-AzNetworkSecurityGroup foreach ($nsg in $nsgs) { $securityrules=$nsg.SecurityRules foreach ($securityrule in $securityrules) { $outputtemp = "" | SELECT  NSGName,NSGLocation,RGName,Direction,Priority,RuleName,DestinationPort,Protocol,SourceAddress,SourcePort,DestinationAddress,Action,Description $outputtemp.NSGName=$nsg.name $outputtemp.NSGLocation=$nsg.location $outputtemp.RGName=$n

Export or Backup Azure Route Table into CSV using PowerShell

Image
 There could be many use cases where you may want to export Azure route tables into CSV. Here is the PowerShell script that you can use to export Azure Route Tables into CSV using PowerShell script. This script will export Azure Route Tables along with routes of all Active subscriptions into a CSV. $outputfinal=@() foreach ( $Subscription in $(Get-AzSubscription| Where-Object {$_.State -ne "Disabled"}) ) { Select-AzSubscription -SubscriptionId $Subscription.SubscriptionId $rts=Get-AzureRmroutetable foreach ($rt in $rts)  {  $routes=$rt.routes  foreach ($route in $routes)  {  $Outputtemp = “” | SELECT RTName,RGName,Location,RouteName,AddressPrefix,NextHopType,NextHopIPAddress $outputtemp.RTName=$rt.name  $outputtemp.RGName=$rt.Resourcegroupname  $outputtemp.location=$rt.location  $outputtemp.routename=$route.Name  $outputtemp.AddressPrefix=$route.AddressPrefix  $outputtemp.nexthoptype=$route.nexthoptype  $outputtemp.NextHopIPAddress=$route.NextHopIPAddress  $outputfinal += $ou

F5 BigIP – Setting up Virtual Server with SSL offload

Image
 In this post we'll be setting up a VIP with a backend pool of three nodes. We have details of backend node IP addresses, which are given by developer team, and VIP address is allocated/secured by us. In our last post, we looked at F5 BigIP Initial Setup and Configuration . First thing first, so lets create an A record in DNS for application FQDN pointing to Virtual Server IP address. To start on F5 BigIP, we'll create Nodes. Navigate to Local Traffic >> Nodes >> Create New Node. Add the server name and Address value in the respective fields. After you add the all the backend nodes, you should be able to see the list of nodes in Nodes section Next step is to create Pools of backend nodes. Navigate to Local Traffic >> Pools >> Create New Pool. Add the Name of the pool, and add backend nodes to the pool that we added in in last step along with port and protocol. Also add the health monitor to be used to monitor the health of backend nodes, so that inactive

F5 BigIP Initial Setup and Configuration

Image
 In this blog post we'll setup and configure a standalone F5 Application Delivery Controller (commonly referred as load balancer). We'll be using a BigIP VM appliance for this lab. Before we begin, we should have following information handy. BIG-IP base registration key Internal/External self IP address, netmask, and default gateway IP address on the management route 1.      After deploying the ova file, when we startup the appliance, we'll be prompted to configure management connectivity. After which we can access the GUI of BigIP using https://<management_IP_address> and default username and password as admin/admin. After login, management IP configuration and admin/root credentials can be updated 2.      Next step is to activate Base registration /add-on license keys  3.     Next step is to enable the modules out of licensed ones, that we want to use. 4.     Its time to configure network settings now. We'll be setting up this BigIP in a single armed mode, where

Ansible-Playbook to display output of multiple show commands (using stdout_lines with Loop)

 In this playbook, we we'll see how we can get display of multiple show commands in stdout_lines format. We can make use of loops (or with_items) for submitting multiple commands, but debug output with stdout_lines does not gives the formatted result as it would give for single command. So in case of multiple commands, we can debug the output of each command separately in stdout_lines format. #Ansible-Playbook to display Output of multiple show commands - name: Display Output of multiple show commands   hosts: all   gather_facts: no   connection: network_cli   become: no   become_method: enable   tasks:    - name: Get the config      cli_command:       command: "{{ item }}"      register: result      with_items:        - show ip access-lists TestACL-1 | include 150        - show ip access-lists TestACL-2 | include 250        - show run | include file|bgp        - show snmp user | i snmp-user    - debug:        msg:          - "{{ result.results[0].stdout_lines }}&quo