Kaseya Community

Agent Procedure to auto name machines

This question is not answered

Calling all agent procedure junkies. I'm looking for input on a new agent procedure.

I'm trying to create a procedure that will read system information and automatically generate a new computer name.

Here is the basic scenario I am envisioning.

- A computer will be given a name that will contain two letters followed by random characters.
- The computer will be added to the network and kaseya will be installed.
- We want an agent procedure to read the computer name and pull out the first two letters to be used in the new name.
- The agent procedure will read the chassis type and look up variables to determine the next character in the new name.
- The agent procedure will read the manufacturer information and look up variables to determine the next character in the new name.
- The agent procedure will read the system serial number and pull out the last 10 digits to finish the new name.
- The complete new computer name will be pushed out to the computer.


The new name will look something like this.

TSWA0123456789

TS - First two letters parsed from the existing computer name
W - (Workstation) Chassis type will be cross referenced with a managed variable
A - (Apple) Manufacture type will be cross referenced with a managed variable
0123456789 - Parsed from the last 10 digits of the serial number


Here is what I have come up with so far:

I have the procedure Execute Shell command to variable for the (Perform Step on: is checked for each OS type):

PC: echo %COMPUTERNAME:~2,2%

MAC: scutil --get ComputerName | cut -c 1-2

It's my understanding that this will be written to a variable called #global:cmdresults#



The next step is creating a variable called #manufacturer# and populating it from a custom DB view that I created.

dbo.hostname_procedure/manufacturer


The next step is creating a variable called #serialnum# and populating it from a custom DB view that I created.

dbo.hotname_procedure/sysSerialNumber


 
I'm a little stuck on parsing these variables and how to get them to be referenced against managed variables, and then how to tie them all together. I'm not even sure this is the right approach for what I'm trying to do. Any advice is greatly appreciated.

All Replies
  • Wouldn't it be a lot easier just to make the actual computer name follow your convention? Then, when the computer is added to Kaseya, it will be correct for you already.

  • In general I agree with you, but I have bosses who want this script to minimize the potential for human error. We will also be using this to rename about 700 machines that have incorrect or old naming conventions. I have another script written that can quickly change the name so the two digit prefix will be correct. It's the time involved to parse the rest of the name together that will take too much time to do manually. Hopefully the total time spent creating the script will in the long run will be worth it.