This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

ResourceImporter.ps1

I wrote this collection of tools to make it easier to manage views for Orion.  Run the ResourceImporter in a powershell window and it will walk you through some prompts to connect to your Orion instance and it will ask you to point it to a specific resource file created by the ViewExporter tool, ViewExporter.ps1​ .  Then it parses the XML file and creates the widget on the specified viewid. Ideally these tools will allow dashboards and widgets to be shared between users to try and develop an ecosystem of views and widgets here on Thwack.

If you need to import an entire dashboard or view then use this tool, ViewImporter.ps1

If you want some sample resources to import you can grab them from the first example dashboard I shared here, SolarWinds Admin Dasboard.zip

I consider this to be a major improvement in usability over the earlier version of the concept I had posted before, viewmigrator.txt

I've been using it pretty regularly myself for some time and haven't been having bugs for a while so I feel like its ready to share.  *Thanks to everyone who has been risking their environments by letting me test it on them over the past year

The attached file is actually just a link to the GitHub repo where I keep these kinds of things, so that way we can ensure that you are always using the most current version in case I have to fix issues that may come up in newer releases.

https://raw.githubusercontent.com/Mesverrum/MyPublicWork/master/ResourceImporter.ps1

This is the actual text of the current version if you can't get to GitHub for some reason

<#------------- FUNCTIONS -------------#>

Function Set-SwisConnection {

  Param(

  [Parameter(Mandatory=$true, HelpMessage = "What SolarWinds server are you connecting to (Hostname or IP)?" ) ] [string] $solarWindsServer,

  [Parameter(Mandatory=$true, HelpMessage = "Do you want to use the credentials from PowerShell [Trusted], or a new login [Explicit]?" ) ] [ ValidateSet( 'Trusted', 'Explicit' ) ] [ string ] $connectionType,

  [Parameter(HelpMessage = "Which credentials should we use for an explicit logon type" ) ] $creds

  )

 

  IF ( $connectionType -eq 'Trusted' ) {

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

  } ELSEIF(!$creds) {

  $creds = Get-Credential -Message "Please provide a Domain or Local Login for SolarWinds"

  $swis = Connect-Swis -Credential $creds -Hostname $solarWindsServer

  } ELSE {

  $swis = Connect-Swis -Credential $creds -Hostname $solarWindsServer

  }

  RETURN $swis

}

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

clear-host

$now = Get-Date -Format "yyyyMMdd_HHmm"

$script = $MyInvocation.MyCommand

if($script.path){ $dir = Split-Path $script.path }

else { $dir = [Environment]::GetFolderPath("Desktop") }

$Logfile = "$dir\$($script.name)_$now.log"

Start-Transcript -Path $Logfile -Append -IncludeInvocationHeader

while(!$swistest) {

  $hostname = Read-Host -Prompt "what server should we connect to?"

  $connectionType = Read-Host -Prompt "Should we use the current powershell credentials [Trusted], or specify credentials [Explicit]?"

  $swis = Set-SwisConnection $hostname $connectionType

  $swistest = get-swisdata $swis "SELECT TOP 1 servername FROM Orion.Websites"

}

"Connected to $hostname Successfully using $connectiontype credentials"

$quit = $null

while ($quit -ne "Quit" ) {

  "`nPlease provide the resource to import"

  $quit = Read-Host 'Press Enter to select file to import, or type [Quit] to exit'

  switch -regex ($quit) {

  "quit" { "`n`nQuitting"; $quit="Quit" ; break}

 

  default {

  Add-Type -AssemblyName System.Windows.Forms

  $inputfolder = New-Object System.Windows.Forms.OpenFileDialog -Property @{

  InitialDirectory = [Environment]::GetFolderPath('Desktop')

  Filter = 'XML (*.xml)|*.xml'

  }

  $null = $inputfolder.ShowDialog()

  $inputfolder = $inputfolder.FileName

  "$inputfolder selected..."

  $resourceproperties = Import-Clixml ("$inputfolder")

  $viewid = Read-Host -Prompt "Which ViewID # should we add this resource to?"

 

  $resourceResults = Invoke-SwisVerb $swis Orion.Views AddResourceToView @($viewid, $ResourceProperties)

 

  "`nCleaning Up"

  $cleanup = Invoke-SwisVerb $swis 'Orion.Reporting' 'ExecuteSQL' @"

update resourceproperties set propertyvalue = replace(replace(propertyvalue, 'linebreak', char(10)),'ampersand',char(38)) where propertyvalue like '%linebreak%' or propertyvalue like '%ampersand%'

update resources set resourcename = replace(replace(ResourceName,'ampersand',char(38)),'doublequotes',char(34)), resourcetitle = replace(replace(ResourceTitle,'ampersand',char(38)),'doublequotes',char(34)), resourcesubtitle = replace(replace(resourcesubtitle,'ampersand',char(38)),'doublequotes',char(34)) where resourcename like '%ampersand%' or resourcetitle like '%ampersand%' or resourcesubtitle like '%ampersand%' or resourcename like '%doublequotes%' or resourcetitle like '%doublequotes%' or resourcesubtitle like '%doublequotes%'

"@

  }

  }

}

"Finished"

Stop-Transcript

Github - ResourceImporter.url