Kaseya Community

Folder

  • I have a question for you guys, I am very new at Kaseya, I would like to make a folder to all my 300 PC's (windows 7 and some XP) users desktop . How can i do that?

    Is there any sample script i can use?

    I will appreciate your help

     

  • There are a number of ways to do that in an agent procedure.

    1. Execute the Shell Command md <foldername>

    2, Execute Powershell new-item -ItemType directory -Path <foldername>

    3, Upload a txt file or other file to the NOC and then use write file to the folder you want created.

  • Like jputman suggests you can use any of those methods but you'll need to use a variable like %userprofile%\desktop to get the folder onto the individual users desktop

  • ahh sorry I didn't notice the fact that you wanted it on the desktop (fault of mine for reading just after getting up).

    You would need to make sure that the script only runs when a user is logged in, or the above noted %userprofile% variable will fail. You could have it check to see if a user is logged in, and reschedule itself if it is not.

    The other option would be if only one user ever uses a specific machine, you could use

    md "c:\documents and settings\#vAgentConfiguration.lastLoginName#\Desktop\folderName"

  • If you want to do this regardless if somebody is logged on or not try this;

    Enumerate the last logged in user's SID and write it into a variable (e.g. #SID#)

    There are many scripts online that can do this but you could try this;

    wmic useraccount where name="#vPatchStatusByAgent.LastLoggedOnUser#" get sid | FIND "S-1-5" >> #LogFile#

    Where #LogFile# is the variable for the file you will store the user SID in until you read it into the #SID# variable

    Get the Registry Key Value and write it into a variable (e.g. #USERPROFILE#)

    HKEY_USERS\#SID#\Volatile Environment\USERPROFILE

    Use the ExecuteShellCommand to execute the following command;

    IF NOT EXIST "#USERPROFILE#\Desktop\#FOLDER#" MKDIR "#USERPROFILE#\Desktop\#FOLDER#" \a

    Where #FOLDER# is the variable for the folder you want to create on the user's desktop