hello to all,
Can anybody tell me i want to learn how to create script in kaseya??
I recommend starting out with the official documentation:
Just drag and drop the "steps" you want to use from the left into your blank agent procedure on the right. Then depending on the step you use, there may be additional fields to enter information into. For example the Get URL step -- you specify the URL to download, and the local path of the file to save it as.
Some tips/tricks after you learn the basics:
* You can use a lot of keyboard keys to manipulate steps in your procedure.
Tab/Shift+Tab will indent/outdent.
Up/down will navigate through the steps.
Del / Delete will delete a step.
Shift+Up/Down will select multiple steps at once (useful if you want to move a bunch of steps into, or out of, an If/Else clause).
* All steps should have context-sensitive help, so if you click the "?" in the upper-right after you've dragged in a step you should get documentation on that specific step.
Good luck and let us know how it goes!
One more thing -- you can download and import agent procedures that others have developed & shared here:
You can edit these agent procedures after you import them, which helps you figure out how advanced agent procedures put all the different steps together.
My piece of advice: For all that I'm old-school enough to still call them "scripts," keep in mind that "procedure" really is a more accurate term. There's no language to learn, which is good because I'm terrible with languages other than English... :)
Figure out what you want the procedure to do. Write down the discrete steps. Can they all be done with registry edits, command line/PowerShell instructions, writing/deleting files? Great. All you have to do is put those steps in order in the procedure editor.
(I know I'm leaving out some things you can do, like calling VB scripts and such. At the beginner level, though, I'm trying to keep to the basics.)
Do you need to make sure only to perform certain steps under a particular condition? Easy, indent those steps under an If check.
And above all, test carefully. Test often. If you're using command lines, capture the output with >> to a text file you can read later to make sure the command runs the way you want it to. If you're using If checks, leave yourself notes in the Agent Procedure log by using Write Procedure Log Entry to mark things like "Step such-and-such was run because of condition X" so when you're debugging the procedure execution on a variety of machines you can track the logic flow.
Its very easy and can be very hard too, it really all depends on what you want to do. First you want to figure out what you want to do and break it up into smaller tasks if what you want to do is complex.
The majority of the tasks that you may want to script for are;1) Auditing (Audit for data that the standard Kaseya audits does not cover)2) Configuration (Registry updates, power configuration etc...)3) Deployment (download, install and uninstall of applications and updates)4) Maintenance (delete temporary files, defragment, repair volumes etc...)
When most people start they write scripts that blindly performs an action and some eventually learn that its not enough, your script needs to check for certain conditions before performing some tasks to prevent the script from causing issues. They also learn that they need to log what actions are taken and if the performed actions were successful or not. (Like Greyduck said capture the output to a text file)
Here are some more tips;
Whenever you refer to a command, file name/path registry key name/path more then once in an agent procedure, put it in a variable this will save you loads of time later if you need to update your agent procedure.
Global procedure variables are very handy when you need to pass values from inside one if statement to another as normal procedure variables can't do this however if you want to pass a procedure variable from primary procedure to a sub procedure you have to use non-global/normal procedure variables.
Something I wish somebody told me when I first started was the existence of Database Views. Database View are agent specific values populated by Kaseya's inbuilt auditing (Base, System and Latest Audits). These values can save you loads of time, I have posted some of the more useful ones here.
Custom Fields is another handy feature that allows you to write values to the Kaseya database for each agent that you can access in other agent procedures, View Filters and Reporting.
Managed Variables are variables you can predefine for all agents in a machine group, this is a very old feature in Kaseya that is underutilized because of the clunky interface but can be very handy.
Augment your Kaseya scriptsLook into using Vb-scripts and PowerShell scripts to augment your agent procedures when the task that you want to perform is too complex, for this you will need to learn how to pass variables to these others scripts and generate output that the agent procedure can read and use if required.
Windows 64bit OS
Learn to write your agent procedures to work for both 32bit and 64bit Windows. You can use the "getOS" If statement to separate 32/64bit procedure commands and learn about the differences in the registry and the Program Files. This is another reason to use variables as the method of writing agent procedures for both 32/64bit generates a lot of duplication.
Computer Vs. User Profile based scriptingSomething to keep in mind is that the Kaseya Agent runs using the local system account and the agent is used to manage the computer and not so much the user profile, its the same for your agent procedures. Figure out if the task you want to script is user profile or computer based. Normally for you to interact with a user profile with a procedure that user needs to be logged on with a console session or the agent procedure against the system account.Permissions (Run As or Execute Privileges)The executeShellCommand and executeFile commands allows you to run the command as User or as System. In most cases as long as the command does not require domain or network permissions you can run the command as System. So if you want to create a folder with the executeShellCommand using the MKDIR command you can use the System user.However say you want to copy a file located on a network share you will need to use the Execute as User option and you need to have the specified the "Use Credentials" or the "Impersonate User" command above it. Personally I prefer to the "Use Credentials" command because it uses the agent credentials and it means I can reuse my agent procedure on other computers as long as their agent credentials are correct.Another way that you can use the Run As User option is if you want to ran a command as the current logged in user, to do this simply omit the "Use Credentials" or the "Impersonate User" command before your executeShellCommand and executeFile commands and use the Run As User option.
Execute and Wait, and Procedure Pauses
Note that the executeShellCommand will always wait until the command completes before it continues and only executeFile has the option to choose between "execute and wait" and "execute and continue". If your executeShellCommand completes faster than expected then its possible that it failed to run correctly, use the pipe command generate a log.
Some execute commands require that you put a pause in between it and the next command especially if the next command relies on the output of the first so experiment with putting in 10sec or greater pauses in place. A good example of this is when you stop or start Windows Services
I don't want to overwhelm you with to much information if you get stuck ask more specific information and we will do the best we can to help
What HardKnox said!
Also, many Kaseya users tend to not use the Standard Solution Packs which include 100's of procedures and policies that can be reused and tweaked to meet your requirements. My recommendation is to start by ensuring you turn that on first and then modify as needed. Don't deploy them all at once!
Go to System -> Orgs/Groups/Dept/Staff ->Manage then click on the System Management tab (which is furthest to the right) and click Configure. This wizard setups all of the standard content including policies and procedures which you can use.
Here is the help file:
Also, there is a some good new training material on university.kaseya.com that you can sign up for free!
Good luck and let us know how you go!