Trying to create a scheduled task on some servers to help with a cert renewal issue, I can't get the command - which works locally - to run in a kaseya procedure.
The command creates a scheduled task and sets some parameters with a xml file. Like I said, works fine running the command from an elevated command prompt locally, but not with the Execute Shell command... i have tried several procedure properties which should i be using for this ?
Can you export the procedure to XML and post it here?
<?xml version="1.0" encoding="UTF-8"?>
-<ScriptExport xmlns="www.kaseya.com/.../Scripting" xmlns:xsd="www.w3.org/.../XMLSchema" xmlns:xsi="www.w3.org/.../XMLSchema-instance"> -<Procedure folderId="95212397413919921721817814" id="2056871124" treePres="3" name="Check SQL Server Certificate Configuration"> -<Body description=""> -<Statement name="ExecuteShellCommand" description="Execute the given command as if it were typed in at a command prompt." continueOnFail="false"> <Parameter name="Command" value="SchTasks.exe /f /create /tn "Check SQL Server Certificate Configuration" /ru BBAAviation\SQLPOSAgent /rp ***** /XML \\cantsee\cantsee$\SQLCertificate.xml" xsi:type="StringParameter"/> <Parameter name="ExecuteAccount" value="System" xsi:type="EnumParameter"/> <Parameter name="Is64Bit" value="False" xsi:type="BooleanParameter"/> </Statement> </Body> </Procedure> </ScriptExport>
cannot import, not in correct format.
I simply exported the procedure and copy pasted it into the reply field... i changed some of the syntax that was unique to my environment, perhaps that's why your having trouble?
this command, before editing it, runs fine and works and the local machines
can't you attache the export here. ( I copied the above text and pasted it in the script editor but no luck )
yes sir, here's the whole thing. any help you can offer is very much appreciated.
You are running this command as a "system" account via Kaseya and it is unable to access the network path you're specifying (e.g. \\cantsee\cantsee$\SQLCertificate.xml).
If you want to reproduce this for yourself outside of Kaseya, you can grab psexec.exe from Pstools and run 'psexec -s cmd.exe' via the command-line. This will get you a fully interactive command shell running as the System account and you should see that if you run your schtasks command, it will fail out with 'network path not found'.
The solution here is to use an 'Impersonate User' step just before your Execute Shell Command step. You'll probably want to enter a domain admin account here with the ability to authenticate to your target network share.
In your Execute Shell step, you'll want to switch it to execute as User as opposed to System. The user in this case will be the previous account you have specified with your Impersonate User step.
I attempted to use Impersonate user as well and did it incorrectly prior to your instruction, I used my account (knowing though testing that my creds would run it successfully) and confirmed that you are in fact correct. Worked like a champ after following your suggestion, you sir may pass go and collect 200 dollars. Thank you!