WUG Ninja: Automate Refreshing Layer 2 & Inventory Information

WUG Ninja: Automate Refreshing Layer 2 & Inventory Information

 

Sometimes scripting takes the Ninja kind of patience.

It took the WUG Ninja some time to arrive at the final script below when trying to sort out how to automate refreshing layer 2 and inventory information (aka device group details). But you sometimes need patience. Like the Ninja kind of patience.

I had tried various methods but found this one to be the most effective.

I ran the script as a Windows scheduled task on my WhatsUp Gold server and it proved successful over many days of testing.

If you want to automate layer 2 and inventory and give this a try, let me know how it goes!

$ErrorActionPreference = "Continue"
Clear-Variable *
#***Configuration
$username = "admin" #Username to login to web interface
$password = "Password1" #Password for the above user
$nDeviceGroupID = "2" #Device group ID of group you want to refresh devices in
#This can be grabbed through SQL by using select * from devicegroup
$url = "https://localhost/NmConsole/Workspace/HomeWorkspace/HomeWorkspace.asp?sUsername=$username&sPassword=$password" #URL for web interface
#***End Configuration
$ErrorActionPreference = "Continue"
$ie = New-Object -com InternetExplorer.Application
$IEpid = (Get-Process -Name iexplore).Id
Write-Host $pid
$ie.visible=$false
$ie.navigate("$url")

while($ie.ReadyState -ne 4)
$Devices | Out-File C:rediscoverdevices.txt
$ie.quit()
taskkill /PID $pid /F

[For reference, this post about layer 2 and inventory originally appeared on my WUG.ninja blog where I have several other items that will help you do things with WhatsUp Gold you may not have known were possible.]

Tags

Get Started with WhatsUp Gold

Subscribe to our mailing list

Get our latest blog posts delivered in a monthly email.

Loading animation

Comments

Comments are disabled in preview mode.