Kaseya Community

Screenshot script

  • Sure Grant:

    Script Name: Take Screenshot
    Script Description: Grabs a screenshot of the current desktop and uploads a time-stamped copy to the VSA. Use Kaseya's "Get Files" function to view the screenshot. Based on script by Resistance2Fly.

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.exe
    Parameter 2 : VSASharedFiles\Executables\Windows XP\MiniCap.exe
    OS Type : 0
    Execute File
    Parameter 1 : "#vAgentConfiguration.agentTempDir#\MiniCap.exe"
    Parameter 2 : -closeapp -capturedesktop -exit -save #vAgentConfiguration.agentTempDir#\screenshot.jpg
    Parameter 3 : 0
    OS Type : 0
    Pause Script
    Parameter 1 : 5
    OS Type : 0
    Get File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\screenshot.jpg
    Parameter 2 : Screenshot-#vAgentConfiguration.machName#.#vAgentConfiguration.groupName#-#vAgentConfiguration.lastCheckin#.jpg
    Parameter 3 : 1
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\screenshot.jpg
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.exe
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.ini
    OS Type : 0
    ELSE



    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: arobar
  • arobar
    The problem with the the $date$ variable in the command line arguments is that we then don't know what the filename is.


    You know, I'd have realized that eventually. Probably right about the time I went to test the script... Big Smile

    I'm glad that the Kaseya variable works!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • mmancini
    Untangle interfaces with Kaseya and $15/month for AD integration reports all internet access by user and can block.


    Can you define "interfaces with kaseya" for me?

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: bruce@dycom.com.au
  • I've used untangle and it's worth noting it doesn't truly integrate with AD. It uses a script on the client pc to associate an IP with a username. unfortunately in a terminal server or citrix environment, or a multiple NAT environment this renders untangle's integration useless.

    I personally use either a dual squid VM, physical box with NTLM auth and some other tools or an untangle box with squid installed (to handle NTLM auth proxying). this won;t give you ALL traffic as a true reflection of the system's throughput but will give you every scrap of web traffic logged against an AD account instead of an IP. that combined with untangle's excellent AV and filtering works well. Only bit missing is group based filtering passed down to untangle from the Squid NTLM handler.....ahh i smell another project.

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: bruce@dycom.com.au
  • Here is another ... using nircmd.exe By the way, if you have not used Nircmd, you should, its a jewel. Small exe and command line based. Lots of stuff can be done with this exe.

    You can download nircmdc.exe from here:
    http://www.nirsoft.net/utils/nircmd.html

    Script Name: Get Screenshot
    Script Description: Gets a screenshot and stores the image by date on the Kserver using Nircmd.

    IF True
    THEN
    Get Variable
    Parameter 1 : 10
    Parameter 2 :
    Parameter 3 : path
    OS Type : 0
    Write File
    Parameter 1 : #path#\nircmdc.exe
    Parameter 2 : VSASharedFiles\nircmdc.exe
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #path#\nircmdc.exe savescreenshot "#path#\shot.jpg"
    Parameter 2 : 0
    OS Type : 0
    Get Variable
    Parameter 1 : 9
    Parameter 2 : #path#\shot.jpg
    Parameter 3 : mytime
    OS Type : 0
    Get File
    Parameter 1 : #path#\shot.jpg
    Parameter 2 : screenshots\#mytime#.jpg
    Parameter 3 : 1
    OS Type : 0
    Delete File
    Parameter 1 : #path#\shot.jpg
    OS Type : 0
    ELSE

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: sjavera
  • Wow, that's quite the piece of software! Controlling the volume, taking a screen shot, turning off the monitor, ejecting the optical drive... A jack of all trades. I'll certainly be using this. Thanks!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: arobar
  • Seconding Alex, here. NirCmd looks like a Kaseya scripter's dream multitool.

    Pardon me, I have some test scripts to go assemble...

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • Yes, its a gold mine. We use it for several script tasks. One of which is to simply drop our training portal website shortcut on each deployed workstation's desktop automatically.


    Enjoy!

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: sjavera
  • Just a quick tweak to the screenshot script using NirCmd: I have an "IF" check for "User Logged In." Otherwise what you get is a lovely rectangle consisting entirely of RGB #000000. *grin*

    (So far, testing indicates that: Getting both parts of dualscreen displays is hit-or-miss, and scripting the screengrab under Vista is a nonstarter. But that's Vista for you.)

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • So I've taken the sample scripts and MiniCap and run with it... thanks to everyone for all the basic work there!

    I've put together a simplified script and combined with Offsite Server to make a fakey mini-Spectre for which I predict huge uptake in my client base!

    Basically I run the script every minute (.01666 hours) or however often is appropriate, but save the screencaps to a "secret" directory, which I then use Offsite/Local server to replicate up to the homebase! Then I have a nice simple directory I can give the execs/managers access to so they can watch over people's shoulders at will!


    Script Name: Client Screenshot
    Script Description: Grabs a screenshot of the current desktop and saves a time-stamped copy to the client temp directory.

    Based on script by Resistance2Fly.

    IF True
    THEN
    Write File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.exe
    Parameter 2 : VSASharedFiles\MiniCap.exe
    OS Type : 13
    Execute File
    Parameter 1 : "#vAgentConfiguration.agentTempDir#\MiniCap.exe"
    Parameter 2 : -closeapp -compress 1 -capturedesktop -exit -save #vAgentConfiguration.agentTempDir#\shots\$datetime$.jpg
    Parameter 3 : 0
    OS Type : 13
    Pause Script
    Parameter 1 : 5
    OS Type : 13
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.exe
    OS Type : 13
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\MiniCap.ini
    OS Type : 13
    ELSE


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: Matthew Bartels
  • Matthew,

    That is both clever and evil. Nicely done!

    (Obligatory Best Practices Moment: My usual response to managers who want to "spy" on their employees is, "No, really, you don't." I point out that spending hours flipping through screenshots of other folks' Excel spreadsheets isn't exactly the most efficient use of their "valuable" time. I can usually even get the "valuable" part out while maintaining a straight face...)

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GreyDuck
  • I took the nircmd idea and created a similar script which takes 10 screenshots, 30 seconds apart (easy to change), compresses them using 7zip and then stores them in the Documents tab for the agent.


    Script Name: Get 10 Screenshots
    Script Description: Gets 10 screenshots, 30 seconds apart using Nircmd. Compresses them into a .7z file and stores the image by date on the Kserver.

    IF True
    THEN
    Execute Shell Command
    Parameter 1 : md "#vAgentConfiguration.agentTempDir#\screenshots
    Parameter 2 : 0
    OS Type : 0
    Execute Shell Command
    Parameter 1 : #vAgentConfiguration.agentTempDir#\nircmdc.exe loop 10 30000 savescreenshot "#vAgentConfiguration.agentTempDir#\screenshots\scr~%currdate.yyyyMMdd%-~%currtime.HH_mm_ss%.jpg"
    Parameter 2 : 0
    OS Type : 0
    Execute Shell Command
    Parameter 1 : cscript #vAgentConfiguration.agentTempDir#\datestamp.vbs #vAgentConfiguration.agentTempDir#\datestamp.txt
    Parameter 2 : 0
    OS Type : 0
    Get Variable
    Parameter 1 : 1
    Parameter 2 : #vAgentConfiguration.agentTempDir#\datestamp.txt
    Parameter 3 : datestamp
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\datestamp.txt
    OS Type : 0
    Execute File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\7za.exe
    Parameter 2 : a -tzip #vAgentConfiguration.agentTempDir#\screenshots-#datestamp#.zip #vAgentConfiguration.agentTempDir#\screenshots\
    Parameter 3 : 1
    OS Type : 0
    Get File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\screenshots-#datestamp#.zip
    Parameter 2 : ../docs/screenshots-#datestamp#.zip
    Parameter 3 : 1
    OS Type : 0
    Delete File
    Parameter 1 : #vAgentConfiguration.agentTempDir#\screenshots-#datestamp#.zip
    OS Type : 0
    Execute Shell Command
    Parameter 1 : del /S /F /Q #vAgentConfiguration.agentTempDir#\screenshots
    Parameter 2 : 0
    OS Type : 0
    ELSE


    Note this relies on nircmdc.exe and 7za.exe being in the agent temp directory. I use "Distribute File" for these common executables to save bandwidth, rather than copying to the agent each time the script is run.

    Also I use a script to get a datestamp, this is also on the agent temp directory of all my agents.

    datestamp.vbs:

    ' Function to return date
    ' Source: http://classicasp.aspfaq.com/date-time-routines-manipulation/can-i-make-vbscript-format-dates-for-me.html
    Function pd(n, totalDigits)
    if totalDigits > len(n) then
    pd = String(totalDigits-len(n),"0") & n
    else
    pd = n
    end if
    End Function

    ' Function to format time
    Function Format(vExpression, sFormat)

    set fmt = CreateObject("MSSTDFMT.StdDataFormat")
    fmt.Format = sFormat

    set rs = CreateObject("ADODB.Recordset")
    rs.Fields.Append "fldExpression", 12 ' adVariant

    rs.Open
    rs.AddNew

    set rs("fldExpression").DataFormat = fmt
    rs("fldExpression").Value = vExpression

    Format = rs("fldExpression").Value

    rs.close: Set rs = Nothing: Set fmt = Nothing

    End Function


    strDateStamp = YEAR(Date()) & Pd(Month(date()),2) & Pd(DAY(date()),2) & "." & format(time(), "hhmm")


    ' Write strDateStamp to a text file
    Dim fso, fl
    Set fso = CreateObject("Scripting.FileSystemObject")
    'OpenTextFile Parameters:
    '-Filename
    '-The 2 is for writing... 1 is reading and 8 is appending
    '-The "True" is to create if not already there.
    Set fl = fso.OpenTextFile(WScript.Arguments.Item(0), 2, True)
    fl.Write(strDateStamp)
    fl.Close : Set fl = Nothing
    Set fso = Nothing

    WScript.Quit


    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: djmundy
  • I use the generation values script to add the date and time to the file name.



    Here is the thread with the scripts: http://community.kaseya.com/xsp/f/28/t/5785.aspx

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: GDRBrian
  • Nice scripts. Just an idea, since the manager is wanting to "spy" on his employees, what about a .vbs that will attach the screen shot and email to him? That is entirely up to you and the manger, but vbs is below. You will need to edit a couple of things, but if you understand vbs even a bit should be able to handle without a problem.

    Set objMessage = CreateObject("CDO.Message")
    objMessage.Subject = "My Space"
    objMessage.From = "you@youremail.com"
    objMessage.To = "them@theiremail.com"
    objMessage.TextBody = "The Body of the server"
    objMessage.AddAttachment "C:\Screenshot.jpg"
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.bellsouth.net"
    objMessage.Configuration.Fields.Item _
    ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objMessage.Configuration.Fields.Update
    objMessage.Send

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: JonJohnston
  • Matthew - Excellent script.
    Ran and tested all working. Thanks

    Legacy Forum Name: Scripts Forum,
    Legacy Posted By Username: luke.bragg