Kaseya Community

Procedure Bug

This question is not answered

All,

I am in need of a learning moment!  I have a client who is having DNS issues with their Windows 2K8 server that requires us to reun the clearcache daily.  I immediately thought of Kaseya and how simple it would be to write a script to handle it.  Well it has been less than simple and I am stumped. 

Can anyone out there in the Forum help me to troubleshoot this?  I have discovered that "Execute File" just fails, "Execute Shell Command" doesn't seem to work and the "ExecuteFile Shell Command - Get Results to Variable" for %WINDIR%\system32\dnscmd.exe comes back with a command not found.  Would anyone have any suggestions or corrections?

I am only trying to run clearcache on the DNS server daily and send a email when it is done.

Anyone?  Thanks in advance...

Page.

  <?xml version="1.0" encoding="utf-8" ?>
- <ScriptExport xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.kaseya.com/vsa/2008/12/Scripting">
- <Procedure name="Clear DNS Cache" treePres="3" id="1320136654">
- <Body description="">
- <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="true" osType="Windows">
  <Parameter xsi:type="EnumParameter" name="VariableType" value="Prompt" />
  <Parameter xsi:type="StringParameter" name="SourceContent" value="Server Name" />
  <Parameter xsi:type="StringParameter" name="VariableName" value="machinename" />
  </Statement>
- <Statement description="Execute the specified file - full path to file required." name="ExecuteFile" continueOnFail="false" osType="Windows">
  <Parameter xsi:type="StringParameter" name="Path" value="%WINDIR%\system32\dnscmd.exe" />
  <Parameter xsi:type="StringParameter" name="Arguments" value="#machinename# /clearcache >> #vAgentConfiguration.agentTempDir#\dnscmd.txt" />
  <Parameter xsi:type="EnumParameter" name="ExecuteAccount" value="System" />
  <Parameter xsi:type="BooleanParameter" name="WaitComplete" value="True" />
  </Statement>
- <Statement description="Create a named procedure variable and assign a value retrieved from the managed machine by the agent." name="GetVariable" continueOnFail="true">
  <Parameter xsi:type="EnumParameter" name="VariableType" value="FileContent" />
  <Parameter xsi:type="StringParameter" name="SourceContent" value="#vAgentConfiguration.agentTempDir#\dnscmd.txt" />
  <Parameter xsi:type="StringParameter" name="VariableName" value="dnscmd" />
  </Statement>
- <Statement description="Send an email from the server (address specified in the Configure function in the System module)." name="SendEmail" continueOnFail="true" osType="Windows">
  <Parameter xsi:type="StringParameter" name="To" value="page@focusdatasolutions.com" />
  <Parameter xsi:type="StringParameter" name="Subject" value="DNS Cache Clear on #machinename#" />
  <Parameter xsi:type="StringParameter" name="Body" value="#dnscmd#" />
  </Statement>
  </Body>
  </Procedure>
  </ScriptExport>

All Replies
  • when you do a Execute shell command are you just running Dnscmd ServerName /clearcache without path or including path.

    When we run Shell commands we generally don't use paths unless the app in question requires it dnscmd should not.

    Are you running as system or logged on user

  • I agree with mmartin that you don't need the path but I wonder if it's a UAC type problem that requires some sort of elevation to run the command.  I know it shouldn't but Kaseya doesn't do things the way you think it will at times.

    Have you tried dropping a batch file - running the batch file which you can pipe the results of to a text file then picking up the text file and emailing to yourself?  Sometimes the old ways work best.

  • Procedure Clear DNS Cache.zip

    Working version of the script attached.  You will need to input email address.  It also uploads using get file as a backup

  • Alistair,

    Thank you for the procedure.  I uploaded it and tried to get it to run but the dnscmd.txt file is empty after the procedure completes successfully.  Am I missing something?

    Thanks,

    Page.

  • Page have you tried dialling into the server and manually running the command?  I suspect the problem lies with the dnscmd app rather than Kaseya in this instance.