7 Replies Latest reply on Aug 3, 2016 1:28 AM by RobLent

    Custom definition to replace a file

    RobLent Specialist

      I need to update/replace a specific file on a number of servers.

       

      The filename is the same on all servers but the file resides in a different folder on each server.

       

      So the filename is myfile.xml but it exists in a structure that is d:\program files\programme\data\0002\myfile.xml

       

      The number part, 0002 in this case, changes from server to server but the rest of the path is the same.

       

      Is there a way to do this with a custom definition?

       

      I don't seem to be able to find a way of using a variable for that specific part of the path.

        • 1. Re: Custom definition to replace a file
          phoffmann SupportEmployee

          You can do programmatical stuff with the script section of a custom definition.

           

          Whether VB, PowerShell or whatever takes your fancy?

           

          Is the "002" side of variation a "random" thing per server, or do you have a master-list (for instance) that "MyServer" needs to have value "001" substituted, while "Bobs-Server" needs to have 002 put in there, as it were?

           

          Should be scriptable either way - depends on what the details are & what sort of scripting resources you have access to, by and large.

          • 2. Re: Custom definition to replace a file
            RobLent Specialist

            Ah so It will need a bit of script work then.  OK.

             

            We do have a list of each server name and the corresponding code number so I can use that.

             

            Thanks for the reply.

            • 3. Re: Custom definition to replace a file
              phoffmann SupportEmployee

              No problem.

               

              "Custom Definition" is just a place holder for a "Do anything you want / need" type operation.

               

              It allows for use of scripts inside the custom definition (you can even go look at our own stuff) - much of which is done with VB, but we're not forcing you down that particular path. As long as it can execute on your box, you can use it (so for NIX-land, you usually would use BASH scripts).

               

              Here's something to get you started / that should help you out:

              - How To: Create a Custom Vulnerability Definition in Patch and Compliance Manager

               

              Hope that helps.

              • 4. Re: Custom definition to replace a file
                RobLent Specialist

                Already read that article thanks.

                 

                Will get onto my scripting guys to sort this one.  ;-)

                • 5. Re: Custom definition to replace a file
                  RobLent Specialist

                  So I am back!

                   

                  I have the definition identifying the file I need to replace no problem.

                   

                  However I am not stuck on the patch install commands to use.  This just needs to replace a file.

                   

                  Am I going to have to create a script to run to replace the file?  I have tried using %patchname% but that just fails.

                   

                  If I am going to have to run a script I may as well just do that outside of LANDesk anyway so I don't quite see the point of the custom definition in this case.  Maybe because it is not really designed to replace files?

                  • 6. Re: Custom definition to replace a file
                    phoffmann SupportEmployee

                    What's your custom def / script section look like?

                     

                    I don't see why you shouldn't be able to replace a / the file (in the mists of my memory, I'm sure I've done it before) ... can't promise I'll get time to look at it this week, but I'll try ...

                    • 7. Re: Custom definition to replace a file
                      RobLent Specialist

                      Please don't worry about this just now.

                       

                      I have replaced the file another way for now.

                       

                      In the end I did not use any custom script as I managed to get the detection rules working fine by using recursive lookup.  I knew the file only existed under a certain folder structure which was the same on every server until the last folder so this worked fine.

                       

                      After scanning all the devices I could see the patch was detected but the only bit that did not work was the actual 'fix'.

                       

                      It would be nice to get this working for future reference as we do have to replace files quite a bit but use a scheduling system which has no logic behind it.

                       

                      Thanks for all your help and advise. It is appreciated.