Kaseya Community

dump client domains to txt file

  • Hi,

    I would like to run a proc on the Kaseya Server to dump all clients domains to a text file. 

    somebody already doing so ? can share a script....

    rgds

  • Surely you could just create and run a custom report through Info Center?

    The field exists under Dataset Name: Agent Configuration Item: Workgroup Domain Name



    added further info
    [edited by: Neal Edgeworth at 1:55 AM (GMT -7) on Sep 16, 2014]
  • Hi Neal,

    thks for the info, but I was more looking for a script running in the evening, creating this list just before starting of some reporting....on backup status...

    rgds

  • so you wish to create a text file out of this list?

  • Hi Flavio,

    yes indeed, I created the file manually this time in order to test the script i'm actually working on, but I would like to have this file created automatically on the Kaseya Server just before kicking off the script on the server

    rgds

  • Hi RDK

    How about running a SQLCMD which pipes the result out to a text file.  You could schedule it with your kaseya server.

    Something along the lines of:

    SQLCMD -S #Servername#-d #database name#  -U #username#-P #password#-Q "select workgroupdomainname from users order by workgroupdomainname" -o "#C:\folder\filename#"

    Replacing the #blurb# with your details but leaving the quotes where used.

  • Hi Alistair,

    thks for the info

    would this be suitable to put in an xml file, so that it can be used with the sqlread statement...or how do you perform this within a procedure ?

    rgds

  • Running it from a sqlread command in an agent procedure is not going to work as it only puts the first line in the variable. I tried it and it is good to know for if I ever wanted to do something like this in the future so your best bet is to run Alistair's SQLCMD command from a executeShellCommand if you want to use an agent procedure.

    I would suggest you update it slightly so that the select statement does this;

    SELECT DISTINCT workgroupDomainName FROM users WHERE workgroupDomainType = 4 order by workgroupDomainName

    If you don't it will list all the domains and workgroups for each of the agents and you will get a lot of duplicate domain names.

    What do you intend to use the domain name list for?

  • Hi HardKnox,

    ok does this mean something like this in the executeshellcommand:

    SQLCMD -S #Servername#-d #database#  -U #username# -P #password# -Q "SELECT DISTINCT workgroupDomainName FROM users WHERE workgroupDomainType = 4 order by workgroupDomainName" -o "c:\waslet\kaseyaagent\domains.txt"

    actually I would like the system to automatically create some files  which can be used as input for some backup reporting such as domain + server running forexample Symantec Backup Exec, same for veeam, Bexec....

    rgds

  • ok, running the command  manually, the file gets created, however when trying to do it from an agent proc, it always fails on the msg variable undefined - no command specified.

  • Just tried it on my sql box and it worked a treat.

    SQLCMD -S SERVERNAME\INSTANCE -d ksubscribers -U USERNAME -P PASSWORD -Q "SELECT DISTINCT workgroupDomainName FROM users WHERE workgroupDomainType = 4 order by workgroupDomainName" -o "c:\temp\domains.txt"

    Just change the red bits to suit - if you don't have more than one SQL instance take out the slash and all after that.

    Can you explain a little further what you're trying to do with the other files as that may help come up with a solution.

  • Hi Alistair,

    have you tried submitting it by an agent procedure ?

    when I run it manually on the kaseya server I don't have any problem. the file gets created. However I entered this in the executeShellcommand entry but nothing gets created.

    FAILED to create THEN step 6, Execute DOS Command. Error = Script variable is undefined. It must be defined by a GetVariable step earlier in this script or a parent script., No command specified

    however all variables are present : Servername / username / password / database

    rgds

  • Procedure SQLCMD Dump.xml

    Yes I did. I've got quite a few simialr to this but the attached is the one you'll need - with a little amendment at your end

  • Hi Alistair,

    some further testing is learning me that the problem is due when trying to work with variables.

    I duplicated the command and hardcoded the different values for servername.... and than it works so might be the syntax when working with variables.

    remaining part now is getting the servernames combined with a custom field.

    on the server I have per domain a folder backup. In there a folder bexec and/or veeam and/or system recovery.

    forexample in veeam folder : a folder per server running veeam :this is  containing last backup info on which I want to report. Before kicking of this reporting I would like to create 3 files:

    veeam machines.txt

    bexec machines.txt

    system recovery machines.txt

    rgds

  • how can I add the names of the servers into this query

    domain x, server1

    domain x, server2

    ...

    domain y, server1

    domain y, server2

    rgds