Skip to content
Darren White edited this page Jan 26, 2019 · 5 revisions

Welcome to the Auvik-PowerShell-Module wiki!

Auvik-PowerShell-Module

PowerShell Wrapper for the Auvik API

Base Module Functions

Add-AuvikBaseURI

Description: Set the URI for API access. Will set Base URI to default of https://auvikapi.us1.my.auvik.com if no option is provided.

Options: [-BaseURI <URL>]  
Options: [-DC <US|EU>]  
Options: [-DC <US#|EU#>]  

Example

Set the Base URI to the US2 Datacenter

Add-AuvikBaseURI -DC US2  

Get-AuvikBaseURI

Description: Returns the URI configured for the current session
Options: None

Remove-AuvikBaseURI

Description: Removes the URI from the current session
Options: None

Add-AuvikAPICredential

Description: Sets a credential for use in the current session

Options: [-UserName <Auvik Username>] [-ApiKey <User API Key>]  

Get-AuvikAPICredential

Description: Returns the current session credential object
Options: None

Remove-AuvikAPICredential

Description: Removes the credential from the current session
Options: None

Export-AuvikModuleSettings

Description: Stores the current session Module Settings including URI and Credential for later use for the current user only.
Options: None

Import-AuvikModuleSettings

Description: Loads previously exported settings.
Options: None

Functions by Endpoint

Credentials

Confirm-AuvikAPICredential

Description: Test the current or provided credential to verify access. Returns the server response or True/False with -Quiet

Options: [-UserName <Auvik Username>] [-ApiKey <User API Key>] [-Quiet]  
Options: [-Credential <Credential Object>] [-Quiet]  

Entity

Get-AuvikEntityAudits

Description: Returns Audit Information

Options: [-ID <List of Audit IDs>]  
Options: [-Tenants <List of Tenant IDs>] [-User <Match for User Name>]  
    [-Category <unknown|tunnel|terminal>]  
    [-Status <unknown|initiated|created|closed|failed>]  
    [-ModifiedAfter <Datestamp for earliest record>]  

Get-AuvikEntityNotes

Description: Returns Note Information

Options: [-ID <List of Note IDs>]  
Options: [-Tenants <List of Tenant IDs>] [-Entities <List of Entity IDs>]  
    [-EntityName <Match for Entity Name>]  
    [-User <Match for User Name>]  
    [-Type <root|device|network|interface>]  
    [-ModifiedAfter <Datestamp for earliest record>]  

Interface

Get-AuvikInterfacesInfo

Description: Returns Interface Information

Options: [-ID <List of Interface IDs>]  
Options: [-Tenants <List of Tenant IDs>] [-Devices <List of Device IDs>]  
    [-InterfaceType <ethernet|wifi|bluetooth|cdma|coax|cpu|firewire|gsm|ieee8023AdLag|inferredWired|inferredWireless|linkAggregation|loopback|modem|wimax|optical|other|parallel|ppp|rs232|tunnel|unknown|usb|virtualBridge|virtualNic|virtualSwitch|vlan|distributedVirtualSwitch|interface>]  
    [-AdminStatus <True|False|Null>]  
    [-OperationalStatus <online|offline|unreachable|testing|unknown|dormant|notPresent>]  
    [-ModifiedAfter <Datestamp for earliest record>]  

Network

Get-AuvikNetworksInfo

Description: Returns Network Information

Options: [-ID <List of Network IDs>] [-IncludeDetailFields <scope,primaryCollector,secondaryCollectors,collectorSelection,excludedIpAddresses>]  
Options: [-Tenants <List of Tenant IDs>] [-Devices <List of Device IDs>]  
    [-NetworkType <routed|vlan|wifi|loopback|network|layer2|internet>]  
    [-IncludeDetailFields <scope,primaryCollector,secondaryCollectors,collectorSelection,excludedIpAddresses>]  
    [-ScanStatus <true|false|notAllowed|unknown>]  
    [-ModifiedAfter <Datestamp for earliest record>]  

Get-AuvikNetworksDetails

Description: Returns Network Details

Options: [-ID <List of Network IDs>]  
Options: [-Tenants <List of Tenant IDs>] [-Devices <List of Device IDs>]  
    [-NetworkType <routed|vlan|wifi|loopback|network|layer2|internet>]  
    [-IncludeDetailFields <scope,primaryCollector,secondaryCollectors,collectorSelection,excludedIpAddresses>]  
    [-ScanStatus <true|false|notAllowed|unknown>]  
    [-Scope <private|public>]  
    [-ModifiedAfter <Datestamp for earliest record>]  

Tenants

Get-AuvikTenants

Description: Returns the list of tenant IDs available for the current user
Options: None

Example

Return all tenants. Return managed devices for each tenant and return device counts for each type of device.

Import-Module AuvikAPI  
If (Confirm-AuvikAPICredential -Quiet) {  
    $AuvikTenants = Get-AuvikTenants | Where-Object {$_.attributes.tenantType -eq 'client'}  
    ForEach ($tenant in $AuvikTenants) {  
        $TenantDevices = Get-AuvikDevicesInfo -Tenant $tenant.ID -IncludeDetailFields manageStatus  
        $ManagedDeviceIDs = $TenantDevices | Select-Object -ExpandProperty 'Included' -ErrorAction SilentlyContinue | Where-Object {$_.attributes.manageStatus -eq 'true'} | Select-Object -ExpandProperty 'ID' -ErrorAction SilentlyContinue  
        $ManagedDevices = $TenantDevices | Select-Object -ExpandProperty 'Data' -ErrorAction SilentlyContinue | Where-Object {$ManagedDeviceIDs -contains $_.ID}  
        $ManagedDevicesGroup = $ManagedDevices | Select-Object -ExpandProperty Attributes -ErrorAction SilentlyContinue | Group-Object -Property deviceType -AsHashTable -ErrorAction SilentlyContinue  
        If ($ManagedDevicesGroup) {  
            Write-Output "Client: $($tenant.attributes.domainPrefix)"  
            ForEach ($deviceType in $ManagedDevicesGroup.Keys) {  
                Write-Output "$deviceType,$($ManagedDevicesGroup.$deviceType.Count)"  
            }  
        }  
    }  
}