Kaseya Community

Transferring Files to Multiple Clients

  • Hi Everyone,

    This is the problem I need help with.

    I have 100 uniquely names files but with the same extension that need to be copied to 100 corresponding clients i.e. filesname 12345.txt needs to be copied to a specific location on the clients.

    Rather than recreate the script 100 times does anyone know of a way that I can write a script that allows me to specifiy a variable in the file name?

    thanks

    jas

    Legacy Forum Name: Transferring Files to Multiple Clients,
    Legacy Posted By Username: jsandu@indexteam.com
  • This is still a bunch of manual work (as you have to setup the variables first), but it will allow you to re-use this variable in the future.


    1. Go to the Scripts tab.
    2. Edit any available script.
    3. In the edit window, click the "Manage Variables" link on the top left.
    4. Use the Variable Manager to create a variable of the same name, but different value, for each client group you have.
    5. In your script, you can then reference the file with ".txt" (for example, ".txt").


    As I said, a bunch of work initially, but if this is something you'll be using more than once, it's reusable.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: arobar
  • Go to scripts and then distribute file. You will have to select the machines that you want each file to go to but its faster than remakeing a script 100 times

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: YLindsay
  • Thank YOu for you help.

    I have defined a variable but the system is asking me to select a source file stored on the server, I do not want to do this as it will try and distribute this file to all machines.

    In theory on the server I will have copied 100 different files with the same extension, each one of these files needs to be distributed to its corresponding servers.

    Thanks

    jas

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jsandu@indexteam.com
  • jas,

    Here is an idea....

    1. Post the 100 files to a publically available website somewhere (ie some folder udnerneath your own hosted site or something).
    2. Wite a script that
    - copies curl-nossl.exe from your kserver to the desired client server.
    - sets the #filename# that is to be downloaded (via managed variable, read from local text file, etc.)
    - execute curl-nossl.exe to download the file from the webserver to the local client server, refering to #filename# in the source, and desination

    Here is a sample script that we use to download SP1 for Windows Vista. It uses variables for the HTTP location and filenames - as we have a template script for performign this task, and then all I need to do it update the HTTP location+filename.

    You will have to
    - edit TargetDrivePath in Step 1 to your specific environment.
    - set Filename in Step 2 based on managed variable, or change to read from local text file, etc.
    - Edit Step 3 to include #filename from step 2, for example: http://yourwebsite/#Filename#
    - Edit email address in Step 4, if you want it to email you when complete, otherwise, delete this step and the last step.

    Hope this helps.

    Lloyd

    =============================
    Script Name: Get Windows Vista SP1 x86 (KB936330) file
    Script Description: Get Windows Vista SP1 x86 (KB936330) file from http location, save to local d:\wolftrack_file_source folder, send email confirmation

    IF True
    THEN
    Get Variable
    Parameter 1 : 2
    Parameter 2 : d:\wolftrack_file_source
    Parameter 3 : TargetDrivePath
    OS Type : 0
    Get Variable
    Parameter 1 : 2
    Parameter 2 : Windows6.0-KB936330-X86-wave0.exe
    Parameter 3 : FileName
    OS Type : 0
    Get Variable
    Parameter 1 : 2
    Parameter 2 : http://download.microsoft.com/download/3/a/9/3a9b72c2-527d-4694-8a49-84c056d4c34d/Windows6.0-KB936330-X86-wave0.exe
    Parameter 3 : URL_plus_Filename
    OS Type : 0
    Get Variable
    Parameter 1 : 2
    Parameter 2 : notifylist@yourcompany.com
    Parameter 3 : EmailAddress
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : TargetDrivePath=#TargetDrivePath# , URL=#URL_plus_Filename# , FileName=#FileName#
    OS Type : 0
    Write File
    Parameter 1 : #TargetDrivePath#\curl-nossl.exe
    Parameter 2 : VSASharedFiles\curl-nossl.exe
    OS Type : 0
    Execute File
    Parameter 1 : #TargetDrivePath#\curl-nossl.exe
    Parameter 2 : #URL_plus_Filename# -k -C - -o "#TargetDrivePath#\#FileName#"
    Parameter 3 : 3
    OS Type : 0
    Write Script Log Entry
    Parameter 1 : Downloaded file #FileName# from #URL_plus_Filename# and saved to #TargetDrivePath#
    OS Type : 0
    Execute Shell Command
    Parameter 1 : eventcreate /L APPLICATION /T INFORMATION /SO WolfTrack /ID 999 /D "Downloaded file #FileName# from #URL_plus_Filename# and saved to #TargetDrivePath#"
    Parameter 2 : 1
    OS Type : 0
    Get Variable
    Parameter 1 : 6
    Parameter 2 :
    Parameter 3 : Machine
    OS Type : 0
    Send Email
    Parameter 1 : #EmailAddress#
    Parameter 2 : #Machine# Downloaded file #FileName#
    Parameter 3 : #Machine# Downloaded file #FileName# from #URL_plus_Filename# and saved to #TargetDrivePath#
    OS Type : 0
    ELSE
    =============================

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Hi Lloyd

    I have followed the steps you mentioned in you previous thread and managed ot get files copied to each server. The problem I have is that the files that are copied have had the contents changed with odd characters hexadecimal

    The script is as follows:

    WHERE have I goine wrong????

    IF True
    THEN
    Write File
    Parameter 1 : \curl-nossl.exe
    Parameter 2 : VSASharedFiles\curl-nossl.exe
    OS Type : 9
    Get Variable
    Parameter 1 : 5
    Parameter 2 : \sims\transfer\in
    Parameter 3 : LocNo
    OS Type : 9
    Get URL
    Parameter 1 : http://www.index.co.uk\download
    Parameter 2 : http://www.index.co.uk\download_#LocNo#.txt
    Parameter 3 : 2
    OS Type : 9
    Write File
    Parameter 1 : \sims\transfer\in\.txt
    Parameter 2 : VSASharedFiles\curl-nossl.exe
    OS Type : 9
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jsandu@indexteam.com
  • jas,

    Hi. I am away on vacaiton this week, and don't have much time to do a lot of testing. But looking briefly at the info you provided, your script does not seem to use the curl-nossl.exe file the way mine does.

    I woudl expect a step for:
    1) Write File step -> to donwload the cur-nossl.exe file from the kserver, which it looks like you have.
    2) Execute File step -> to download the file from a publicly availabel website, using the cur-nossl.exe program. In my case, the script Step is:

    Execute File
    Parameter 1 : #TargetDrivePath#\curl-nossl.exe
    Parameter 2 : #URL_plus_Filename# -k -C - -o "#TargetDrivePath#\#FileName#"
    Parameter 3 : 3

    I didn;t see that exact step in your script.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Hi Lloyd

    I followed your script with the line I had not inserted. When I know look at the file that is copied to the remote server, rather than the file containing the correct details it contains the following...

    !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    You are not authorized to view this page


    BODY { font: 8pt/12pt verdana }
    H1 { font: 13pt/15pt verdana }
    H2 { font: 8pt/12pt verdana }
    A:link { color: red }
    A:visited { color: maroon }



    You are not authorized to view this page


    You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept.


    Please try the following:



    • Contact the Web site administrator if you believe you should be able to view this directory or page.

    • Click the Refresh button to try again with different credentials.


    HTTP Error 401.2 - Unauthorized: Access is denied due to server configuration.
    Internet Information Services (IIS)




    Technical Information (for support personnel)



    • Go to Microsoft Product Support Services and perform a title search for the words HTTP and 401.

    • Open IIS Help, which is accessible in IIS Manager (inetmgr),
      and search for topics titled About Security, Authentication, and About Custom Error Messages.



    Sad

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jsandu@indexteam.com
  • jas,

    Hellol. That looks like you are getting the HTML code for a "You are not authorized to view this page" message.

    Try this:
    1) open IE

    2) type in the URL for the file you are trying to download (for example: http://somewebsite/somefilename.exe and his enter. For example, here is the URL+filename for the latest Microsoft Malicious Software Removal Tool
    http://download.microsoft.com/download/4/a/a/4aa524c6-239d-47ff-860b-5b397199cbf8/windows-kb890830-v2.1.exe

    3) you should get a prompt to download the file (ie Run, Save, Cancel)

    I think if you manually type in the http://URL+filename inside IE, that you are trying to download from for your script, you will see a "You are not authorized to view this page" message.

    Get the website working to be able to grab the file using IE, and I think the script will then work.

    I hope this helps.

    Lloye

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Hi Lloyd,

    Many Thanks for your help in this matter.

    regards

    jasSmile

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jsandu@indexteam.com
  • jas,

    You are very welcome. Does it seem to be working now?

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf
  • Yes,

    You were right about the web page setting.

    Once I had set the correct permissions to see the folder via Internet Explorer the script worked a treat!!

    thank you

    :-)

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: jsandu@indexteam.com
  • Great. Glad to hear.

    Lloyd

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: lwolf