
Mike Rockwell (Progress Software) asked a question.
Currently, there isn't a way to get a list of all attributes for all or a few devices. So I wrote this PowerShell script which will create an HTML file which you can put on a custom Dashboard view using the Free Form Text/HTML report. This takes advantage of the WhatsUpGoldPS PowerShell Module created by @Jason Alberino (Progress Software Company) . The script will check to see if WhatsUpGoldPS is installed, and install it for you, however, you may need to run it as Administrator. You should run this ON your WhatsUp Gold server, but you don't have to. Just enter the appropriate info to make it work, like your WUG server, and a userID and password.
- <#Checking to see if WhatsUpGoldPS module is installed,
- if not install it! You may have to run this with elevated permissions.#>
- if (-not (Get-Module -Name WhatsUpGoldPS)) {
- Import-Module WhatsUpGoldPS
- }
-
- #Initialization Variables
- $wugServer = "LOCALHOST" #This is the hostname or IP address of your WUG server, if running on WUG server, use LOCALHOST
- $userID = "" #Enter a user who is has Access to WUG with API rights (API rights are the same as WUG user rights)
- $pwd = "" #Enter the password for the user. If you don't want to save it here, see this: https://pscustomobject.github.io/powershell/howto/Store-Credentials-in-PowerShell-Script/
-
- $searchString = "1" #this is the search sting to find a specific device. 1 for all devices
-
- #WUG regkeys - Don't modify these
- $regKey = 'HKLM:\SOFTWARE\Wow6432Node\Ipswitch\Nm.UI_WUG'
- $itemName = 'InstallDir'
-
- #Output file path and file name
- $outFilePath = "" #if you are running this on the WUG server, you can leave it blank or otherwise put the path to save in
- $outFileName = "deviceAttributes.html" #you can change this if you want
-
- #******Function to get path to WUG HTML if run on WUG server*****
- Function Get-RegistryValue ($regKey, $itemName) {
- $filePath = ""
- if ((Get-ItemProperty -Path $regKey -Name $itemName)) {
- $filePath = (Get-ItemProperty -Path $regKey -Name $itemName ).$itemName + "\NmConsole"
- }
- else {
- [void][Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic')
- $title = 'Save File Path'
- $msg = 'Enter the path to save the file:'
- $filePath = [Microsoft.VisualBasic.Interaction]::InputBox($msg, $title)
- }
- return $FilePath
- }
- #*****End Function*****
-
- #Setting the file path if run on the WUG Server
- if([string]::IsNullOrEmpty($outFilePath)){
- $outFilePath = Get-RegistryValue -regKey $regKey -itemName $itemName
- }
-
- #building the PowerShell Credential
- $securePwd = ConvertTo-SecureString $pwd -AsPlainText -Force
- $cred = New-Object System.Management.Automation.PSCredential ($userID, $securePwd)
-
- #Building the HTML to write to file - DON"T change this
- $htmlText = "<style> table {border-collapse: collapse;width: 100%;}th, td {text-align: left;padding: 8px;}tr[name='devices']:nth-child(odd) {background-color: Lightgrey;}</style><table>"
-
- #Connecting to WUG API
- Connect-WUGServer -serverUri $wugServer -Credential $cred
-
- #Getting the device(s)
- $devices = Get-WUGDevices -View card -SearchValue $searchString -Limit 500 | Select-Object id, name, networkAddress
- #Looping thought the devices returned
- foreach ($device in $devices) {
-
- $htmlText += "<tr name='devices'><td><details><summary>$($device.name) : $($device.networkAddress)</summary><table>" #adding to the html to output
-
- #Getting the deivce Attributes
- $devAttributes = Get-WUGDeviceAttributes -DeviceID $device.id | Select-Object name, value
-
- #Looping through the attributes
- foreach ($attrib in $devAttributes){
- $htmlText += "<tr><td alight='right'>$($attrib.name)</td><td>$($attrib.value)</td></tr>"
- }
- $htmlText += "</table></details></td></tr>"
- }
- $htmlText += "</table>"
-
- #Writing the output file
- Out-File -FilePath ($outFilePath + "\" + $outFileName) -InputObject $htmlText
If you add the Free Form Text/HTML report, click on the </> button and enter this
- <iframe src="/deviceAttributes.html" width="100%" height="100%"></iframe>
That is if you used the default file name. If you changed the name, well, change it here too.