• Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy
Cybersylum

Cybersylum

  • Home
  • VMware QuickDocs
    • Getting Started with VMware Cloud Foundation
    • VMware General
    • vSphere
    • vSAN
    • Horizon
    • NSX
    • vRealize Suite (renamed to Aria Suite)
    • Aria Suite
      • Aria Automation
      • Aria Operations
      • Aria Operations for Logs
      • Aria Automation Orchestrator
    • Podcasts
  • Home Lab
  • VMware Stickers
  • mac OS Tips
  • About Me
    • Privacy Policy
    • Cookie policy

Importing vSphere Networks into Aria Automation – Part 1 – Export Networks with Missing IP Info

byArron King 10.15.2023 Aria Automation Importing vSphere Networks into Aria Automation

If you are standing up a new Aria Automation environment and have a large number of vSphere Networks (aka Port Groups), it could take a very long time to enter this information manually.  I have written a few scripts that can make Importing vSphere networks into Aria AutomationAria Automation fairly easy!

This blog article is the 1st in a 4-part series that discusses how you can import vSphere Networks into Aria Automation.  The environment these scripts were written for has multiple vCenter Server instances – each with multiple clusters.   The network infrastructure is using Layer 2 stretched VLANs.  As a result the same VLAN can exist in multiple locations.  The vSphere Port Groups are all named the same, and have the same characteristics.

Blog Series Overview –  Importing vSphere Networks into Aria Automation

  1. Export Networks with Missing IP Info – This will export a file that can be used to determine which networks need updated.  This will be the basis for the other 3 sections as an input file to target updates.  This file will need updated with the pertinent IP information.
  2. Update Network IP Info – This script will use the file created in step 1 to update the IP Information for vSphere networks discovered by Aria Automation
  3. Update IP Ranges – This script will use the file created in step 1 and define IP Ranges for the subnets used by the discovered vSphere Networks
  4. Update Network Profiles – The final step is to take the results from the prior 3 steps and create Network Profiles that can be used by Aria Automation for workload deployment

Export Networks with Missing IP Info

Aria Automation will discover vSphere Port Groups that exist in any Cloud Accounts that have been configured.  This will create definitions in Infrastructure -> Resources -> Networks -> Networks; but does not necessarily populate the necessary IP Information.

Aria Automation - vSphere Network missing IP Info

 

 

 

 

 

 

In order to deploy workloads to these environments using Aria Automation, a Network Profile needs to be created.  This profile requires Network IP Information and IP Ranges to be defined for each vSphere Network.

The first step is to identify all discovered vSphere Networks that need to have this information updated.  While you can certainly click through the GUI and manually update each one, this does not scale well in environments with large numbers of vSphere Port Groups.  Manual data entry at this scale also dramatically increases the likelihood of inadvertent errors.

The script below will create a CSV file listing the discovered vSphere Networks in Aria Automation that is missing the basic IP Information required.

  • Domain
  • IPv4 CIDR
  • IPv4 Default Gateway
  • DNS Servers
  • DNS Search Domains

There are more fields available for each network.  If you require these in your environment, it should be a pretty easy task to extend the script to add support for these (IPv6, tags, checkboxes for Public IP/Default for Zone).

The Script

Requirements

  • Powershell – written and tested using 7.3.8
  • PowervRA –  This script was written and tested with Power vRA 6.0.  Make sure to use PowervRA 4.x and above.   Earlier versions were compatible with vRealize Automation 7.x.  The APIs in Aria Automation 8.x are completely different

Usage

You will need to edit the script and enter a few details about your environment:

  • $vRAServer – FQDN of the Aria Automation Server
  • $vRAUser – name of the user used for authentication to Aria Automation
  • $ImportFile – path the the CSV input file
  • $RunLog – path the log file

When executed, the script will prompt you to choose a Cloud Account to export from.  It can export all; but I have found that working with one Cloud Account at a time is easier.

  • The script assumes that all Networks with the same name have the same characteristics.  It will update all discovered networks regardless of Cloud Account. For example, if you have 3 Cloud Accounts that all have the same network (VLAN101); but you run through the process in this blog series for 1 Cloud Account and include information on VLAN101 in the input file – All 3 instances of VLAN101 will be updated.
  • If you start with the largest cloud account first and run through the entire process with it, you can follow up with other cloud accounts and clean up any one-off networks that exist

Executing the script

Output

The script will create a file with a list of networks that do not have IP information configured in Aria Automation.

Output file for Export-Empty-CIDR-Networks

 

 

 

 

 

 

 

For the next steps, you will need to take that data and create an input file with the following column names (exactly as shown).  The file should be in the CSV format.   This is a manual process and should be validated before proceeding.

  • PortGroup (VLAN315)
  • Gateway
  • SubnetMask
  • NetworkAddress
  • CIDR
  • StartAddr
  • LastAddr

 

If you are new to using APIs with PowerShell,  check out my article on Using Aria Automation APIs with PowerShell.

Getting the Code

Tips
Test environments are your friend. Make sure your Aria Automation environment is backed up and take snapshots to save yourself time and agony

You can download the script from GitHub.

<#
Export-Networks-Empty-CIDR.ps1

This script will export a list of vSphere Networks that have been discovered by Aria Automation 
which have not been configured with IP Information.

The script provides a prompt to allow a choice of all networks or networks associated with a 
specific Cloud Account.

Disclaimer:  This script was obtained from https://github.com/cybersylum
  * You are free to use or modify this code for your own purposes.
  * No warranty or support for this code is provided or implied.  
  * Use this at your own risk.  
  * Testing is highly recommended.
#>


# define vars for environment
$vRAServer = "vra8.domain.com"
$vRAUser = "[email protected]"
$DateStamp=Get-Date -format "yyyyMMdd"
$TimeStamp=Get-Date -format "hhmmss"
$ExportFile = "empty-cidr-networks-$DateStamp-$TimeStamp.csv"

#QueryLimit is used to control the max rows returned by invoke-restmethod (which has a default of 100)
$QueryLimit=9999

$Error.clear()

Write-Host "Connecting to Aria Automation -  $vRAServer as $vRAUser"
$vRA=connect-vraserver -server $vRAServer -Username "$vRAUser" -IgnoreCertRequirements
if ($null -eq $vRA) {
    write-host "Unable to connect to vRA Server '$vRAServer'..."
    exit
}

#Grab the bearer token for use with invoke-restmethod (which is needed for queries with more than 100 results)
$APItoken= $vRA.token | ConvertTo-SecureString -AsPlainText -Force

$Body = @{
    '$top' = $QueryLimit
}
$APIparams = @{
    Method = "GET"
    Uri = "https://$vRAServer/iaas/api/cloud-accounts"
    Authentication = "Bearer"
    Token = $APItoken
    Body = $Body
}

try{
    $CloudAccounts = (Invoke-RestMethod @APIparams -SkipCertificateCheck).Content
} catch {
    Write-Host $("    Unable to get Cloud Accounts from Aria Automation")
    Write-Host $Error
    Write-Host $Error[0].Exception.GetType().FullName
}

Write-Host "Cloud Accounts found - " $CloudAccounts.Count
Write-Host ""
Write-Host "Choose a Cloud Account to use for Network Export:"
$Index=0
foreach ($Account in $CloudAccounts) {
    Write-Host "    " $Index " - " $Account.Name " ("$Account.id")"
    $Index++
}
Write-Host "   99 - All Cloud Accounts"
write-host ""
$Choice= Read-host -Prompt 'Enter selection and hit &amp;amp;amp;lt;ENTER&amp;amp;amp;gt; or just &amp;amp;amp;lt;ENTER&amp;amp;amp;gt; to quit'

if ($Choice.length -eq 0) {
    exit
}

try {
    $Selection = [int]$Choice
}
catch {
    write-host "$Choice is not a valid selection- exiting..."
    exit
}

if ($Selection -ne 99) {
    $InRange = $Selection -In 0..($Index-1)
    if (-Not $InRange) {
        write-host "$Choice is not a valid selection- exiting..."
        exit
    }
}

if ($Selection -eq 99) {
    $DisplayCloudAccountName = "All Cloud Accounts"
    $CloudAccountID = ""
} else {
    $DisplayCloudAccountName = $CloudAccounts[$Selection].name
    $CloudAccountID = $CloudAccounts[$Selection].id
}

#Get All Networks Discovered by vRA - so we can filter later if necessary
$Body = @{
    '$top' = $QueryLimit
}
$APIparams = @{
    Method = "GET"
    Uri = "https://$vRAServer/iaas/api/fabric-networks-vsphere"
    Authentication = "Bearer"
    Token = $APItoken
    Body = $Body
}

try {
    $Networks = (Invoke-RestMethod @APIparams -SkipCertificateCheck).content
} catch {
    Write-Host $("    Unable to get networks from vRA")
    Write-Host $Error
    Write-Host $Error[0].Exception.GetType().FullName
}

write-host "Networks discovered by vRA - " $Networks.count

if ($CloudAccountID -eq "") {
    #Use All Networks discovered by vRA
    $FilteredNetworks = $Networks    
} else {
    #Filter to matching CloudAccount
    $FilteredNetworks = $Networks | where-object -Property cloudAccountIds -eq $CloudAccountID
}

$EmptyNetworks = @()
Write-Host "Scanning networks in $DisplayCloudAccountName for missing IP Info - " $FilteredNetworks.Count 
foreach ($ThisNetwork in $FilteredNetworks) {
   #write-host $ThisNetwork.name " - " $ThisNetwork.cidr
    if ($ThisNetwork.cidr.length -eq "") {
        #write-host $ThisNetwork.name
        $EmptyNetworks += $ThisNetwork.name
    }
}

Write-host "Networks with missing IP info - " $EmptyNetworks.count
 
$EmptyNetworks | out-file -filepath $ExportFile

# Clean up
write-host "list exported to $ExportFile"
Disconnect-vRAServer -Confirm:$false

Next Steps

The next article in the series is Update Network Info on vSphere Networks.  It will discuss how to take this information and use it to Update the Network definitions in Aria Automation.

 

Share this:

  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn

vToolbelt - October 2023

Importing vSphere Networks into Aria Automation - Part 2 - Update Network IP Info

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Search

Disclaimer

The content and opinions on this site belong to me - not my employer.

You are welcome to use any ideas or code from this site. You have the responsiblity to test these before using in a production environment.

Upcoming Events

  • Wed
    22
    Oct
    2025

    Cincinnati VMware VMUG UserCON

    Save The Date!

    The VMware VMUG UserCON returns to Cincinnati in October 2025

Categories

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10

Archives

Category

Aria Automation Aria Operations for Logs Before I Forget Certificates Education Home Lab Horizon View Importing vSphere Networks into Aria Automation Linux MacOS Networking PowerCLI Professional Development Scripting Swift TechBITS Tech Learning Update Manager VCSA VMUG VMware VMware Cloud on AWS VMware Portal VMware Tools VMworld vSphere vToolBelt Windows 10
Proudly powered by WordPress | Theme: Showme by NEThemes.
 

Loading Comments...