Guys please help me with the ps script which will migrate all custom property field from one Orion to new Orion
Do you just need the properties and their attributes or do you want to get the properties and their values to move across?
For the first part you could use a variation on this script
<#------------- 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 target host and credentials$hostname = 'localhost'#$user = "admin"#$password = "password"# 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 -------------#># build the array of properties: #PropertyName - name of the property to modify.#Description - a description of the property to be shown in editing UI.#Size - for string types, this is the maximum length of the values, in characters. Ignored for other types.#Values - a list (in string[] format) of allowed values for this property. An empty or null list has the effect of allowing any value.#ValidRange System.String, usually $null#Parser System.String, usually $null#Header System.String, usually $null#Alignment System.String, usually $null#Format System.String, usually $null#Units System.String, usually $null#Usages - optional. Defaults to not changing the allowed usages of the existing property.#Mandatory - optional. Defaults to false. If set to true, the Add Node wizard in the Orion web console will require that a value for this custom property be specified at node creation time.#Default - optional. Defaults to null. If you provide a value, this will be the default value for new nodes.##example query to pull from an existing environment#SELECT concat('@{ PropertyName = "',Field,'"; ') as PropertyName#, concat('Description = "',Description,'"; ') as Description#, concat('ValueType = "',DataType,'"; ') as ValueType#, concat('Size = "',MaxLength,'"; ') as Size#FROM Orion.CustomProperty#where table='NodesCustomProperties'$propertiestocreate = @( @{ PropertyName = "_testing4"; Description = "This is to change the device polling method. ICMP, WMI, SNMP, AGENT."; ValueType = "nvarchar"; Size = "400"; ValidRange = "$null"; Parser = "$null"; Header = "$null"; Alignment = $null; Format = "$null"; Units = "$null"; Usages = "$null"; Mandatory = 1; Default = "$null" }, @{ PropertyName = "DataCenter"; Description = "This is the DataCenter where this node is located."; ValueType = "nvarchar"; Size = "400"; ValidRange = "$null"; Parser = "$null"; Header = "$null"; Alignment = "$null"; Format = "$null"; Units = "$null"; Usages = "$null"; Mandatory = "$null"; Default = "" })# iterate over the arrayforeach ($prop in $propertiestocreate) { # write out which property we're working with "Working with Property: $($prop.PropertyName)" #check if property already exists $propexists = get-swisdata $swis "SELECT field FROM Orion.CustomProperty where table='NodesCustomProperties' and field = '$($prop.propertyname)'" if ($propexists.count -eq 0) { " $($prop.PropertyName) does not already exist, creating..." Invoke-SwisVerb $swis Orion.NodesCustomProperties CreateCustomProperty @("$($prop.PropertyName)","$($prop.Description)","$($prop.ValueType)","$($prop.Size)",$null,$null,$null,$null,$null,$null,$null,$null,$null,$null) } else { " $($prop.PropertyName) already exists, skipping" }}
It has to be modified for each type of property, applications, alerts, volumes, etc but basically the format is exactly the same, just executing the command to the different table names as appropriate.