powershell - 同一网络上远程桌面的屏幕截图
问题描述
我是 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/
解决方案
推荐阅读
- html - 当我向下滚动页面时,如何让我的导航栏向下滚动
- compression - 重新创建的 LZMA 在 332 字节后与原始 LZMA 不同 - 可能吗?
- angular - 如何更好地构建 Observables 链(如果第一次返回 null 则退出)
- arrays - 将哈希数组与 ruby 中的正则表达式进行比较
- javascript - (集成 P5.js 和 Three.js)--- 使用 P5.js 库中的动画创建 ThreeJS 场景?
- java - Jersey 测试中的请求返回 404
- javascript - 使用数组时如何修复谷歌图表不显示?
- vba - MS Access - 使用子表单过滤时禁止保存提示
- c# - Xamarin.forms 将默认文本放在编辑器类中的多行
- unreal-engine4 - 如何在虚幻引擎 4 中获取帧缓冲区?