首页 > 解决方案 > 同一网络上远程桌面的屏幕截图

问题描述

我是 IT 公司的一名新手新员工,担任系统信息管理员,我的老板给了我一个项目:在不通知他们的情况下截取网络中远程机器的屏幕截图。他们也不应该与他们的会话断开连接。我正在寻找任何 3d 派对软件(免费或其他)或任何 powershell 脚本来帮助我解决这个问题。我的进步:


用于在本地保存屏幕截图的 PowerShell 脚本:

$Path = "C:\Users\Naskez\Desktop\Screenshots"
If (!(test-path $path)) {
New-Item -ItemType Directory -Force -Path $path
}
Add-Type -AssemblyName System.Windows.Forms
$screen = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds

$image = New-Object System.Drawing.Bitmap($screen.Width, $screen.Height)

$graphic = [System.Drawing.Graphics]::FromImage($image)
$point = New-Object System.Drawing.Point(0, 0)
$graphic.CopyFromScreen($point, $point, $image.Size);
$cursorBounds = New-Object System.Drawing.Rectangle([System.Windows.Forms.Cursor]::Position, [System.Windows.Forms.Cursor]::Current.Size)

[System.Windows.Forms.Cursors]::Default.Draw($graphic, $cursorBounds)
$screen_file = "$Path\" + $env:computername + "_" + $env:username + "_" + "$((get-date).tostring('yyyy.MM.dd-HH.mm.ss')).png"

$image.Save($screen_file, [System.Drawing.Imaging.ImageFormat]::Png)

之后,如果要从 RDS 服务器(或桌面 Windows,其中允许多个并发 RDP 连接)获取桌面屏幕截图,则必须首先获取远程计算机上的用户会话 ID。在以下 PowerShell 脚本中指定远程计算机/服务器的名称和用户帐户:

$ComputerName = "nld-rds1"
$RDUserName = "h.jansen"
$quser = (((query user /server:$ComputerName) -replace '^>', '') -replace '\s{2,}', ',' | ConvertFrom-Csv)
$usersess=$quser | where {$_.USERNAME -like $RDUserName -and $_.STATE -eq "Active"}
$usersessID=$usersess.ID

然后最后用正确的 sessionID 执行 Psexec :

.\PsExec.exe -s -i $usersessID \\$ComputerName powershell.exe -executionpolicy bypass -WindowStyle Hidden -file "\\nld-fs01\Screen\CaptureLocalScreen.ps1"

问题是:我的公司不允许多个 RDP 连接。所以如果我尝试这样做,我必须断开它们。

任何解决方案或提示将不胜感激。

注意:上面列出的 PowerShell 解决方案不是我的。原文链接如下: http ://woshub.com/take-user-desktop-screenshot-with-powershell/

标签: powershellscreenshotmonitoringrdpadministration

解决方案


推荐阅读