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.

Renaming nodes to match DNS

FormerMember
FormerMember

Currently we have quite many nodes with their IP on SAM. What would be the easiest way to rename those on what the hostname is? I know how to fetch these nodes from SAM with the SDK but my skills with powershell pretty much ends in here and I have no clue which way to go.

  • Travel day so pardon the short response.

    So when adding a node Orion uses DNS name if it can get one. If you have a bunch of IP's for caption then did you add DNS after adding into Orion or are there no DNS at all?

    I would query through SDK nodes whose caption <> DNS.

    Let this fill DNS and URI variables. Start there.

    Then you can write a ForEach($item in $URI) { "insert sdk verb to update caption with DNS"}

    Test this manually before trying inside a ForEach.

    I know you said hostname vs DNS but string manipulation can handle that.

  • Hello mikkok,

    I would use SQL for this task,

    UPDATE NodeData set Caption=DNS where DNS !=''

    This would update the caption for all nodes to the value in the DNS field where the DNS field has a value

    To preview the changes you could run

    select dns,caption from NodesData where DNS !=''

    Thanks,

    Tony

  • The recommended way to set the caption from powershell would be this:

    $uri = ... get the node uri from somewhere ..

    $dns = ... get the node's dns name from somewhere ...

    Set-SwisObject $uri @{Caption=$dns}

  • Too ironic, I just did this in my system. Except I didn't want the FQDN, We wanted to use the short name. I went with the SQL update path.

    ## First let's see how many results we have that look like an IP Address

    SELECT   SUBSTRING(DNS, 1, (CHARINDEX('.', DNS, 0)-1))

      FROM    [SolarWindsOrionNA].[dbo].[Nodes]

      WHERE Caption like '10.%'

      AND       (DNS is not null OR DNS != '')

      AND       DNS like '%.%'

     

      ## Now let's run update on the previous result set

      UPDATE  [SolarWindsOrionNA].[dbo].[Nodes]

      SET         Caption = SUBSTRING(DNS, 1, (CHARINDEX('.', DNS, 0)-1))

      WHERE  Caption like '10.%'

      AND        (DNS is not null OR DNS != '')

      AND        DNS like '%.%'