3 Replies Latest reply on Apr 17, 2015 12:41 PM by Gjstewart

    Using Query string as Database Value?

    Gjstewart Specialist

      In provisioning you can add a Database Value as a Public or Action Variable.

       

      I use this for many things however I have something I wanted to try. For this example I have a new managed software file extension i have added to ldapple3 and my scans are collecting the data. Lovely jubbly.

       

      When i run a query on said file i can add the column for Path and see it in the console. Again all good.

       

      Its that Path that i want to use as a Variable. And i am thinking there must be a way.

       

      I could use a script to identify the file i want to replace and find its current location (as its a random path on each machine) and overwrite it but i am trying to see if the information i already have in the Database can be used. If so its a simple one action provisioning template with file copy action source \\server\file Dest %TESTVAR%

       

      So the Database Query is.

       

      "Computer"."Software"."Package"."FileName"="FILE.EXT"

       

      I want this information.

       

      "Computer"."Software"."Package"."FileName"="FILE.EXT"."Path"

       

      So i Create a Public variable called TESTVAR with the Database Value above and try and call it in my provisioning Template.

       

      I end up with (by design) extra Fields in my inventory Schema... So under Computer \ Software \ Package \ there is a new Inventory container called FileName with FILE.EXT and Path under it.. not good. But no result returned from the TESTVAR variable.

       

      This is I am guessing because its a query string not a static Database value.

       

      But can you get that "Path" value from the Database and use it as a Public Variable? Can you use a database query as a Database Value?

       

      Where in the Database is the Managed software file path?

       

      It may need some tinkering but as that "Path" is in the Database there must be a way to use it?

       

      Anyone else wanted to do this? Or worked out how?

        • 1. Re: Using Query string as Database Value?
          rmeyer SupportEmployee

          You cannot use a query in a variable. All variables do is substitute the database value pointed to in place of the variable. It is that simple.

          • 2. Re: Using Query string as Database Value?
            rmeyer SupportEmployee

            The problem is that the DB value you are looking for is a one to many relationship in the database. The computer has lots of files so you cannot use them in a variable. You can only use DB values that have a one to one relationship in the DB like a computer name. The computer only has one computer name.

            • 3. Re: Using Query string as Database Value?
              Gjstewart Specialist

              I managed to sort this using the MBSDK. Initially i wanted to grab the Database value and use it as a variable in Provisioning directly but this way I can create the variable within the Powershell code and grab the data that way.

               

               

              $LDWebService = (New-WebServiceProxy -Uri http://CORESERVER/MBSDKService/MsgSDK.asmx?WSDL -Credential $Cred)

               

              $QueryName = "QUERYNAME"

              $Result = $LDWebService.RunQuery($QueryName)

               

              foreach ($Row in $Result.Tables[0].Rows)

              {

                write-host "value is : $($Row[0]) $($Row[5])"

               

              }

               

              This gave me the values for Row 1 and Row 5

               

              Row 1 was the Device Name and Row 5 was the Managed Software File Path for the file in question.

               

              example of Data Returned.

               

              value is : COMPUTERNAME C:\ORACLE\ORA11G\NETWORK\ADMIN\LDAP.ORA

               

              So i found all machines with the file in question and also the path of that file as it is located in many different places.