cancel
Showing results for 
Search instead for 
Did you mean: 

Clone the new Map tab onto all your custom details views

So for those of you who run heavily customized environments you may have noticed that the new maps view only gets added to the default node details view.  I wrote this script that looks through all the views, figures out which ones could have a Maps tab and clones it in for you.  All you need to do is run the below powershell on your Orion server under a Windows account with view customizing permissions and in 2 seconds it will add the maps tab to all your custom versions of the details views.  I've tested it pretty extensively in my lab but as always take a backup of your db before you run any scripts and let me know if you get any unexpected results.

pastedImage_0.png

<#------------- CONNECT TO SWIS -------------#>

# load the snappin if it's not already loaded (step 1)

if (!(Get-PSSnapin | Where-Object { $_.Name -eq "SwisSnapin" })) {

    Add-PSSnapin "SwisSnapin"

}

#define host, credentials, and sql connection string

$hostname = 'localhost'

#$user = "user"

#$password = "pass"

# create a connection to the SolarWinds API

#$swis = connect-swis -host $hostname -username $user -password $password -ignoresslerrors

$swis = Connect-Swis -Hostname $hostname -Trusted

<#------------- ACTUAL SCRIPT -------------#>

# get list of all views types with a map option

$viewkeys = get-swisdata $swis "SELECT distinct ViewKey FROM Orion.Views where viewtitle = 'map' and viewkey like '%StaticSubview' "

foreach ($viewkey in $viewkeys)

    {

"Working on $viewkey"

        #get the viewgroup to use for our parent clone

$mapviewgroup = get-swisdata $swis "select top 1 viewgroup from orion.views where viewkey = '$viewkey'"

        #this will be the viewid of the parent of our clones

$cloneviewparent = get-swisdata $swis "select viewid, uri from orion.views where viewgroup = '$mapviewgroup' and viewkey = '$viewkey'"

" View to clone is $($cloneviewparent.viewid)"

#get the correct viewkey

$viewkeytoadd = get-swisdata $swis "select viewkey from orion.views where viewgroup = '$mapviewgroup' and (viewgroupposition = 1 or viewgroupposition is null)"

#find any instances of that viewtype that don't already have a map

$viewgrouptoadd = get-swisdata $swis "select viewgroup, viewgroupname, viewkey, viewtype, viewgroupposition from orion.views where viewkey = '$viewkeytoadd' and viewgroup not in (select viewgroup from orion.views where viewkey like '$viewkey%')"

"Number of view groups to clone into is $($viewgrouptoadd.viewgroup.count)"

foreach ($vg in $viewgrouptoadd.viewgroup )

{

$vieworder = get-swisdata $swis "select viewgroupname, max(viewgroupposition)+1 as position from orion.views where viewgroup = '$vg' group by viewgroupname "

"  Cloning map to $($vieworder.viewgroupname) position $($vieworder.position)"

              

               $newview = Invoke-SwisVerb $swis Orion.Views CloneView @($cloneviewparent.viewid , "Map")

"   New Viewid is $($newview.'#text')"

$newviewuri = get-swisdata $swis " select uri from orion.views where viewid = $($newview.'#text')"

"   New view Uri is $newviewuri"

Set-SwisObject $swis -Uri "$newviewuri" -Properties @{"ViewGroupName"="$($vieworder.viewgroupname)"; “ViewGroup” = "$vg"; "ViewGroupPosition"="$($vieworder.position)" }

            }

    }

-Marc Netterfield

    Loop1 Systems: SolarWinds Training and Professional Services

Comments

SW users: "I wish I could customize my Orion dashboards in this one very specific way, but it's not possible"

mesverrum​: "Hold my beer"

Every problem most people run into as a solarwinds owner is a one time nuisance, for me its a nuisance I see again and again each week with each new client.  Repetitive tasks are jobs for computers, not me.

Any way to do the same thing for Cloud Resources? We are running custom views for different machine types (Windows, Linux etc) we aren't getting the cloud resource tabs for cloud linked nodes.

Ill double check later but I think this should work to do that with pretty simple changes.

Have you had any time to take a look? Looks like we are also missing out on the new interfaces tab, along with the maps and cloud tabs.

Version history
Revision #:
1 of 1
Last update:
‎09-06-2018 06:27 PM
Updated by: