Kaseya Community

Retrieve admin first name and last name as variables

  • From within an Agent Procedure, I am trying to retrieve the actual name of an admin running it. I  have tried using "#adminDefaults.adminName#" but this returns the username, not the Full Name listed under the System > Users page.

    I also tried passing this through to a custom SQL Read to retrieve it, but this also fails:

    <?xml version="1.0" encoding="utf-8" ?>
    <queryList>
    <queryDef label="Select AdminFirstName" sql="SELECT firstName FROM vSystemUsers where userName = '#adminDefaults.adminName#'" />
    <queryDef label="Select AdminLastName" sql="SELECT lastName FROM vSystemUsers where userName = '#adminDefaults.adminName#'" />
    </queryList>

    If I manually run an SQL query on the DB server SELECT firstName FROM vSystemUsers where userName = 'stephen...' it returns my name correctly, but doesn't seem to pass the variable down to the query.

    Help!

  • Hmm Not sure as it seems to work on my system.  I just created the sql read, with the following line in one of my existing files:

    <queryDef label="WhoAdmin" sql="Select firstName + ' ' + lastName FROM vSystemUsers where userName = '#adminDefaults.adminName#'" />

    and did a quick two liner, one to run the sqlRead and return it to a variable, and then wrote that variable to the procedure log.   I ran it on a machine, and it correctly showed my first and last name in the procedure log.

  • Thanks Johnathan. It's all working now. It was a syntax issue on my part...i had ` instead of '...rookie mistake!