3 Replies Latest reply on Jul 28, 2015 3:30 PM by fcpsolaradmin

    Sync information to orion from various sources

    fcpsolaradmin

      I am attempting to synchronize information from VMware, AD, and SCCM into my Orion environment. So far I am working with the following custom properties.

       

       

      Backup_Policy-- Taken from VM note field

       

      OS_Update_Schedule--calculated based on active directory membership

       

      Comments--Based on description from AD

       

      Here is what I have:

       

       

       

      #Clear Variables

       

      $server= @()

      $NodeDetail=@()

      $Description=@()

      $NodeNumber=@()

      $servername=@()

      $Backup_policy=@()

      $Memberof=@()

      $IP=@()

       

      ##Gather Inforamtion

       

      Get-ADComputer  -Filter {OperatingSystem -Like "Windows Server*"} -SearchBase "OU=Test ,DC=local" -Properties Name, Description, ipv4address, memberof | Foreach-Object{

       

           $NodeDetail = New-object -TypeName PSObject -property @{

          Server= $_.name

          Backup_Policy= Get-VM $_.Name | Select-Object -ExpandProperty Notes

          Description = $_.description

           NodeNumber = Get-OrionNodeID -Swisconnection $swis -NodeName $_.name

          IP=$_.ipv4address

          memberof=$_.memberof

       

             }

       

       

       

      If ($NodeDetail.NodeNumber -gt "0")

       

             {$ServerList += $NodeDetail}

       

      Else{$AddtoOrion +=$NodeDetail}

       

      }

       

       

       

      $NodeNum=$nodedetail.NodeNumber

       

      $NodeDesc=$nodedetail.Description

       

      $BackupPol=$nodedetail.Backup_Policy

       

      $UpdateSchedule=$nodedetail.memberof

       

       

       

       

       

      ##Sync Gathered Info with SW

       

      foreach ($server in $ServerList)

       

      {

       

       

       

       

       

      If ($UpdateSchedule-eq "CN=MW-SRV Thursday,OU=Maintenance Windows ")

       

        {

       

          $Customproperties=@{

       

              Comments=$nodedetail.Description;

       

              Backup_Policy=$nodedetail.Backup_Policy;

       

      OS_Update_Schedule="Thursday following patch Tuesday";

       

              }

       

             Set-SwisObject $swis  swis://./Orion/Orion.Nodes/NodeID=$nodenum/CustomProperties $Customproperties

       

        }

       

       

       

              Elseif ($UpdateSchedule -eq "CN=MW-SRV Sunday 2,OU=Maintenance Windows")

       

            {

       

                     $Customproperties=@{

       

                     Comments=$nodedetail.Description;

       

      Backup_Policy=$nodedetail.Backup_Policy;

       

                     OS_Update_Schedule="Sunday following patch Tuesday"

       

      }

       

                  Set-SwisObject $swis swis://./Orion/Orion.Nodes/NodeID=$nodenum/CustomProperties $Customproperties

       

            }

       

                      Elseif ($UpdateSchedule -eq "CN=MW-SRV Sunday 3,OU=Maintenance Windows")

       

                        {

       

                        $Customproperties=@{

       

      Comments=$nodedetail.Description;

       

      Backup_Policy=$nodedetail.Backup_Policy;

       

      OS_Update_Schedule="2nd Sunday following patch Tuesday"

       

      }

       

                        Set-SwisObject $swis swis://./Orion/Orion.Nodes/NodeID=$nodenum/CustomProperties $Customproperties

       

      }              

      }

       

       

      (I had this working, however I made some revisions that got saved, I went on vacation now I am back it is no longer working. The broken code is above.  I do not understand how I got it to work before so now I am reaching out for help       )

       

      Now when I run it, it doesn't create any errors. It just doesn't update Orion. Looking for advice on how I can sync the information from the multiple sources to orion.

       

      Thank you

        • Re: Sync information to orion from various sources
          tdanner

          Some things I would look at to try to debug this:

           

          1. What changed? Have there been any updates to Orion or the SDK since it was last working?
          2. Try a basic custom property update at the powershell command line using Set-SwisObject. Does it work as expected in isolation?
          3. Use the PowerShell ISE debugger to step through your script. Does the control flow match what you expect?
            • Re: Sync information to orion from various sources
              fcpsolaradmin

              It does update the first device it finds in the OU. So for some reason its not doing the next server in the list.

               

              for each ($nodenumber in $serverlist)

              {write-host "hello"}

               

              it will write hello twice (which is correct as this is how many servers are in my test OU)

              and if I do $serverlist.count it will show 2

              • Re: Sync information to orion from various sources
                fcpsolaradmin

                Ok I got it working again.

                 

                foreach ($nodenumber in $ServerList)

                 

                $NodeNum=$nodenumber.NodeNumber

                 

                $NodeDesc=$nodedetail.Description

                 

                $BackupPol=$nodedetail.Backup_Policy

                 

                $UpdateSchedule=$nodedetail.memberof

                 

                If ($UpdateSchedule-eq "CN=MW-SRV Thursday,OU=Maintenance Windows,")

                 

                   $Customproperties=@{

                 

                  Comments=$nodenumber.Description;

                 

                  Backup_Policy=$nodenumber.Backup_Policy;

                 

                  OS_Update_Schedule="Thursday following patch Tuesday";

                 

                Set-SwisObject $swis  swis://./Orion/Orion.Nodes/NodeID=$nodenum/CustomProperties $Customproperties