Author Posts

April 14, 2016 at 10:07 am

Evenign all

I was wondering if its possible to take a screenshot for a remote users screen.

My script is for desktop support users and one of them asked is it possible to do this.

So when a users says whats this on my screen you can do a quick screen capture instead of going through the whole remote assist.

I was thinking if it's possible i would try and get the script to send a confirmation message to the user before running the script

Any assistance would be appriciated

April 14, 2016 at 10:32 am

Look at this post: http://www.adminarsenal.com/admin-arsenal-blog/capturing-screenshots-with-powershell-and-net/

And instead of using that tool what is suggested there, you can use Invoke-Command to execute the code on the remote computer. See this blogpost: https://4sysops.com/archives/use-powershell-invoke-command-to-run-scripts-on-remote-computers/

April 14, 2016 at 11:34 am

While not what you're asking, I think PSR is ideal for these scenarios (problem step recorder, been built-in for awhile now). Have them run PSR, hit record, then recreate the problem. It will save screenshots and actions into a zip for you (up to 100 steps, so don't try to leave it on all day).

August 8, 2018 at 7:26 pm

I know this is an old post, but no external tools necessary for this (taking screenshot of remote PC without remoting on).  Powershell only.  See below:

Basically this will ask for a PC and user name.  It will copy over a script (Screenshot_Desktop.ps1) to the temp directory of the remote PC and will then capture the correct session ID.  It will then start the script on the remote pc and deposit the screenshot in the remote PC's temp directory.  There is a brief flash on the remote PC when screenshot it taken.

Script to trigger Screenshot_Desktop.ps1 below:

Write-Host "THIS ONLY WORKS IF SCREEN IS NOT LOCKED"
Write-Host " "

$ComputerName = Read-Host -Prompt 'PLEASE ENTER PC NAME'
$UserName = Read-Host -Prompt 'PLEASE ENTER USER ID'

# Copies script to remote PC
copy-item "C:\Temp\SCREENSHOT_DESKTOP.ps1" "\\$ComputerName\C$\Temp"

#Captures correct session ID

$results = psexec \\$ComputerName query session
$id = $results | Select-String "$UserName\s+(\w+)" |
Foreach {$_.Matches[0].Groups[1].Value}

# Allows script to execute on remote PC

psexec \\$ComputerName POWERSHELL set-executionpolicy remotesigned

#Takes screenshot of remote PC

psexec -s -i $id \\$ComputerName POWERSHELL -WindowStyle Hidden -file "C:\Temp\SCREENSHOT_DESKTOP.ps1"
######################################################

Screenshot_Desktop.ps1 script copied to remote PC from above:

$File = "C:\Temp\Screenshot1.bmp"
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
# Gather Screen resolution information
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
$Top = $Screen.Top
# Create bitmap using the top-left and bottom-right bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
# Create Graphics object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
# Capture screen
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
# Save to file
$bitmap.Save($File)
Write-Output "Screenshot saved to:"
Write-Output $File

# That's it.  Hope this helps people looking for a Powershell Only solution.