Capture Screen on Server Desktop Session

Capture Current Desktop Session using Boot Diagnostics

You can do this with the RDP shadow function.

See https://support.microsoft.com/en-gb/help/292190/how-to-shadow-a-terminal-server-session-without-prompt-for-approval

To connect remotely you can use:

query session /server:[hostname-of-VM]

Then call the RDP client as follows:

mstsc.exe /v:[hostname-of-VM] /shadow:[id]

Capturing screenshots of a minimized remote desktop

You have to temporarily restore the window, capture, and minimize it again. This link shows how to do it silently

How to take a remote screenshot with Powershell

So I got this to work but it is a little involved. Works with multiple monitors.

You will need Screenshot.ps1 on the remote PC, your trigger script and PSExec on local PC (Google).

# This is Screenshot.ps1
# Add types and variables
$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

# Set bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height

# Create Object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)

# Capture
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)

# Save
$bitmap.Save($File)

And then for the trigger script

#Setup Variables
$ComputerName = "ComputerName"
$PSExec = "C:\temp\tools\psexec.exe"

# Captures session details
$quser = (((query user /server:$ComputerName) -replace '^>', '') -replace '\s{2,}', ',' | ConvertFrom-Csv)

# Takes screenshot of remote PC
&$PSExec -s -i $quser.ID "\\$ComputerName\" PowerShell -WindowStyle Hidden -File "C:\Temp\screenshot.ps1"


Related Topics



Leave a reply



Submit