Powershell – Solarwinds – Get Devices Connected to Switch Ports

To get powershell access to Solarwinds Orion you need to install the SDK 

https://github.com/solarwinds/OrionSDK

The powershell module installed is

SWISPowershell

 

The best way to visually see what you are getting back is to first use SWQL Studio that in installed on your device when you install the SDK

Here is some example powershell code to get back the device and what switch port it is on

#Solarwinds Server
$SolarwindsServer = "SolarwindsServer"
#Username password is a local username password for Solarwinds
$SolarwindsUser = Read-Host -Prompt "Username"
$Password = Read-Host -Prompt "Password"
$swis = Connect-Swis -UserName $SolarwindsUser -Password $Password -Hostname $SolarwindsServer

#Get Connected devices, what port and switch they were connected to and when last seen
Get-SwisData $swis 'SELECT LastSeen, MACAddress, RawMAC, AdministrativeStatus, OperationalStatus, PortType, NodeAccessPoint, ClientSSID, NodeStatus, NodeStatusIcon, PortIcon, IPAddress, PortDescription, PortName, HostName, VendorIcon, ShutdownIcon, MACVendor, EndpointID, IsWireless, IsRWCommunityDefined, NodeID, PortID, MacUrl, PortUrl, APUrl, HostNameUrl,
                    MEMBERS.ContainerID, MEMBERS.MemberPrimaryID, MEMBERS.MemberEntityType, MEMBERS.Name
                    FROM Orion.UDT.MACCurrentInformation UDT
                    JOIN Orion.ContainerMembers MEMBERS   ON UDT.NodeID = MEMBERS.MemberPrimaryID
                    '

#Get Container(group)members returns nodes and the container they are in
Get-SwisData $swis 'SELECT ContainerID, MemberPrimaryID, MemberEntityType, Name, Status, MemberUri, MemberAncestorDisplayNames, MemberAncestorDetailsUrls, EntityDisplayName, EntityDisplayNamePlural, FullName, DetailsUrl,ContainerMembers.Container.Displayname AS ContainerName
                         FROM Orion.ContainerMembers

 

Leave a comment

Your email address will not be published. Required fields are marked *

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