PowervRNI

PowervRNI

  • Getting Started
  • Examples
  • Example Snippets
  • Videos
  • GitHub
  • Blog

›PowervRNI

PowervRNI

  • Getting Started

Examples

  • Example Scripts
  • Example Snippets

Videos

  • Videos

Getting Started

Starting vRealize Network Insight (vRNI) 3.6, the platform has a public API. PowervRNI is a PowerShell module that takes advantage of those public APIs and provides you with the option to look at vRNI data using PowerShell.

This module is not supported by VMware, and comes with no warranties express or implied. Please test and validate its functionality before using this product in a production environment.

Installing PowervRNI

There are 2 ways of installing PowervRNI. An easy one through PowerShell Gallery where everything is taken care of for you, or a slightly harder one where you download the module and load it up manually.

PowerShell Gallery

PS C:\> Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
PS C:\> Install-Module PowervRNI
PS C:\> Import-Module PowervRNI

That's it, the module is now installed and loaded - ready for use. The first command sets a trust for the PowerShell Gallery, as by default it's not a trusted source and the installation will be blocked.

Manual Download

Right now, PowervRNI is a simple two-file module. To install it, download it to a PowerShell enabled machine and load it. PowervRNI is supported for PowerShell Desktop & Core, so Windows, MacOS and Linux. Here is an example on how to load it:

PS C:\> Invoke-WebRequest -Uri "https://raw.githubusercontent.com/powervrni/powervrni/master/PowervRNI.psm1" -OutFile "PowervRNI.psm1"
PS C:\> Invoke-WebRequest -Uri "https://raw.githubusercontent.com/powervrni/powervrni/master/PowervRNI.psd1" -OutFile "PowervRNI.psd1"
PS C:\> Import-Module .\PowervRNI.psd1

Updating PowervRNI

To update the PowerVRNI module, either download it manually (see above commands), or use the PowerShell Gallery to update. It's as simple as:

PS C:\> Update-Module PowervRNI

Connecting to vRealize Network Insight

Before you can do anything with the API, you need to authenticate. With PowervRNI, this means executing Connect-vRNIServer or Connect-NIServer. There are 2 versions of vRealize Network Insight: an on-premises version, and vRealize Network Insight Cloud (SaaS, run and maintained by VMware). The authentication on vRNI Cloud is handled differently, which is why there is a separate connect function.

vRNI

PS C:\> $creds = Get-Credential

PowerShell credential request
Enter your credentials.
User: msmit@vmware.com
Password for user msmit@vmware.com: *****************

PS C:\> Connect-vRNIServer -Server vrni-platform.lab -Credential $creds

vRNI Cloud

Connecting to vRealize Network Insight Cloud (the SaaS offering), is a bit different. This is because the VMware Cloud Services Portal (CSP) handles the authentication to the VMware Cloud Services, and not the vRNI product itself. In order to connect to the vRNI Cloud API, you need something that's called a Refresh Token. This Refresh Token can be generated in the CSP web interface.

After getting the Refresh Token, use the Connect-NIServer function to authenticate against vRNI Cloud, before executing any other PowervRNI functions.

PS C:\> Connect-NIServer -RefreshToken thelongstringthatisyourrefreshtoken

Disconnecting from vRealize Network Insight

Every time an authentication request is done against vRNI, an authentication token is created. While these expire, if there's enough authentication requests, the limit of the number of authentication tokens can be reached, and subsequent authentication requests will fail. To prevent this, delete the authentication token using Disconnect-vRNIServer, when you're done executing your script.

PS C:\> Disconnect-vRNIServer

This is the same for both on-premises vRNI and vRNI Cloud.

Possiblities (Functions)

PowervRNI brings a bunch of functions. To get a feel for what the possibilities are, get a list of all functions using Get-Command:

PS C:\> Get-Command -Module PowervRNI

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Add-vRNIEastWestIP                                 1.7.119    PowervRNI
Function        Add-vRNINorthSouthIP                               1.7.119    PowervRNI
Function        Connect-NIServer                                   1.7.119    PowervRNI
Function        Connect-vRNIServer                                 1.7.119    PowervRNI
Function        Disable-vRNIDataSource                             1.7.119    PowervRNI
Function        Disconnect-vRNIServer                              1.7.119    PowervRNI
Function        Enable-vRNIDataSource                              1.7.119    PowervRNI
Function        Get-vRNIAPIVersion                                 1.7.119    PowervRNI
...truncated...

The function names relate to what it does. Meaning, Enable-vRNIDataSource enabled a data source. After getting the list, and finding the functions you need; get some more information on the specific functions.

Finding help with Get-Help

Every function has documentation built in. This documentation can be accessed with the Get-Help function. For example:

PS C:\> Get-Help New-vRNIApplication

NAME
    New-vRNIApplication

SYNOPSIS
    Create a new Application container inside vRealize Network Insight.


SYNTAX
    New-vRNIApplication [[-Name] <String>] [-Connection <PSObject>] [<CommonParameters>]


DESCRIPTION
    Within vRNI there are applications, which can be viewed as groups of VMs.
    These groups can be used to group the VMs of a certain application together,
    and filter on searches within vRNI. For instance, you can generate recommended
    firewall rules based on an application group.

...truncated...

This explains what the function does, what the parameters are, and how it fits into vRNI. To get even more information, you can use the Get-Help -Examples parameters, to get examples on how to run the PowervRNI function:

PS C:\> Get-Help New-vRNIApplication -Examples

NAME
    New-vRNIApplication

SYNOPSIS
    Create a new Application container inside vRealize Network Insight.


    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>New-vRNIApplication -Name My3TierApp

    Create a new application container with the name My3TierApp.

While this function is relatively simply (so, just 1 example), most PowervRNI functions have 2-4 examples on how to use them.

Explore

This page has taken you through the basic tools to get PowervRNI installed, loaded, connected to vRNI [Cloud], and how to get a list of functions and their purpose + examples. The best thing to do now, is explore: go through the function list, see what data (flows, VMs, Hosts, etc.) you'd like to pull out of vRNI (or push/configure vRNI), look at the examples, and try them.

Then start building your own scripts, using the PowervRNI functions. Or have a look at the example scripts, on the next page.

Example Scripts →
  • Installing PowervRNI
    • PowerShell Gallery
    • Manual Download
  • Updating PowervRNI
  • Connecting to vRealize Network Insight
    • vRNI
    • vRNI Cloud
  • Disconnecting from vRealize Network Insight
  • Possiblities (Functions)
  • Finding help with Get-Help
  • Explore
PowervRNI
Docs
Getting StartedExamplesVideos
Community
Follow @powervrni
More
BlogGitHub
Copyright © 2021 Martijn Smit