18 Replies Latest reply on Sep 12, 2014 2:50 PM by clum09

    Add WMI node with CRUD.AddWMINode.ps1 failed

    clum09

      Hello,

       

      I am new to this forum. I downloaded the Swis SDK 1.9 and installed on my computer.

       

      I tried to test adding a WMI node to the Orion monitoring system in my environment using the sample PowerShell script "CRUD.AddWmiNode.ps1" from the SDK.  I edited the script match my settings before I ran it, but the script failed at line 75 where it attempted to add the node. The error was:

       

      New-SwisObject : Entity â€EntityType Orion.Nodes â€Properties not found.

      At C:\Scriptings\powershell\server_build\v1.7\CRUD.AddWMINode.ps1:93 char:15

      + $newNodeUri = New-SwisObject $swis –EntityType "Orion.Nodes" –Properties $ne ...

      +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

          + CategoryInfo          : InvalidOperation: (:) [New-SwisObject], FaultException`1

          + FullyQualifiedErrorId : SwisError,SwisPowerShell.NewSwisObject

       

      What did I do wrong?

       

      I greatly appreciate it if someone can let me the reason why this script failed.

       

      Thanks.

        • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
          tdanner

          The error message is strangely formatted with some odd characters. Maybe some curly quotes got introduced into the script?

            • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
              clum09

              There is no curly quotes in the script. The sample script that came with the SDK 1.9 was what I used. I just edited some settings in the script to match my environment and launched the script. The Orion version is 6.1.

                • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                  Jan Pelousek

                  Hello,

                  which Script editor do you use? Or if you just use something like Notepad, here it looks like you changed the codepage while saving.

                    • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                      clum09

                      I used PrimalScript 2012 to edit the script. There should not be any change to the characters in the script. I don't know if this could be the permission issue or not, but the script simply failed at the line where it attempted to add the WMI node. Below is the part of of code I used after I have successfully made the connection to the Orion server.

                       

                      # Helper function

                      function ip2guid($ipString) {

                          $ip = [System.Net.IPAddress]::Parse($ipString)

                          $src = $ip.GetAddressBytes();

                          $data = new-object byte[] 16

                          $src.CopyTo($data, $data.Length - $src.Length)

                         $dest = new-object byte[] 16

                          [Array]::Copy($data, 12, $dest, 0, 4)

                         [Array]::Copy($data, 10, $dest, 4, 2)

                         [Array]::Copy($data, 8, $dest, 6, 2)

                         [Array]::Copy($data, 6, $dest, 8, 2)

                         [Array]::Copy($data, 0, $dest, 10, 6)

                         return (New-Object Guid (,$dest)).ToString()

                      }

                       

                      $ip = "10.10.1.101"

                      $ipGuid = ip2guid($ip)

                       

                      # Node properties

                      $newNodeProps = @{

                          EntityType="Orion.Nodes";

                          IPAddress=$ip;

                          IPAddressGUID=$ipGuid;

                          DynamicIP=$False;

                          EngineID=1;

                          Status=1;

                          UnManaged=$False;

                          Allow64BitCounters=$true;

                          SysObjectID="";

                          MachineType="";

                          ObjectSubType="WMI";

                          Location="Mylocation";

                          Contact="";

                          Description="";

                          IOSImage="";

                          RediscoveryInterval=30;

                          PollInterval=120;

                          StatCollection=10;

                      }

                       

                      #Creating the node

                      $newNodeUri = New-SwisObject $swis –EntityType "Orion.Nodes" –Properties $newNodeProps

                       

                      It just failed at the above line with the error I posted earlier.

                       

                      Thanks.

                        • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                          tdanner

                          This line:

                           

                          $newNodeUri = New-SwisObject $swis –EntityType "Orion.Nodes" –Properties $newNodeProps

                           

                          Should be this:

                           

                          $newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

                           

                          Those look almost identical, but the - character in -EntityType and -Properties has been changed from a regular hyphen to some kind of typographic dash character. PowerShell doesn't like it.

                            • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                              clum09

                              tdanner,

                               

                              Thank you for pointing this out. Actually, the sample scripts that came with the SDK 1.9 have a longer dash (hyphen) character on some of the parameter lines. That was the reason why the script failed.

                               

                              One more thing I still have a problem is I am not able to add the WMI credential for the node which is handled by the follow code:

                               

                              $credentialName = 'mycredentialname' # from Manage Windows Credentials of the Settings page.

                               

                              #Getting the Credential ID

                              $credentialId = Get-SwisData $swis "SELECT ID FROM Orion.Credential where Name = '$credentialName'"

                              if (!$credentialId) {

                                  Throw "Can't find the Credential with the provided Credential name '$credentialName'."

                              }

                               

                              #Adding NodeSettings

                              $nodeSettings = @{

                                  NodeID=$nodeProps["NodeID"];

                                  SettingName="WMICredential";

                                  SettingValue=($credentialId.ToString());

                              }

                               

                              #Creating node settings

                              $newNodeSettings = New-SwisObject $swis -EntityType "Orion.NodeSettings" -Properties $nodeSettings

                               

                              What did I do wrong?

                               

                              Thanks again.

                                • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                                  tdanner

                                  You did nothing wrong. I looked at the original script that we ship in the SDK package and it has exactly the same problem. I have now corrected this, so the next release will get this right. I'm sorry for the confusion.

                                    • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                                      clum09

                                      tdanner,

                                       

                                      Thank you for the information.

                                       

                                      When will the next release of the SDK package be available?

                                       

                                      Also, I forgot to mention that when the ran the code to add the WMI credential for the node, it seemed to temporarily wipe out the Windows credentials on the list I have on the Manage Windows Credential page for some reason, and this list will return after a period of time.

                                        • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                                          tdanner

                                          We don't have a target date for an SDK update right now.

                                           

                                          Re: the Manage Windows Credentials page. That sounds very strange. We don't have an API for modifying the set of Windows credentials (just picking a pre-existing one for use with a WMI node), so it's not clear to me how this script could affect that page. Could you describe what you saw in more detail?

                                            • Re: Add WMI node with CRUD.AddWMINode.ps1 failed
                                              clum09

                                              tdanner,

                                               

                                              Basically, after I launched the script code to add the WMI credential that I listed on my previous post and then I went to the Orion webpage Settings, Manage Windows Credentials page,  and I tried to browse for the credential names that were list on the table of that page, I could not find them on that page.

                                               

                                              The the table on that page had a header of Credential name, User name, Assigned to nodes. On that table, I could not any entries right after I had launched the code to add the WMI credential for the node. It wiped out the list, but the list would return after about one hour or so.