Categories
Development

How to take a remote screenshot with Powershell

I’m trying to figure out how to take remote screenshots over PowerShell from an administrator’s account on the AD server to any computer on the network.

So far I’ve got the following.

 $ComputerName = '<THECOMPUTER>'

 copy-item "C:\Public\Software\Take-Screenshot.ps1" "\\$ComputerName\C$\"

 Invoke-Command -ComputerName $ComputerName -ScriptBlock {
     powershell -nop -c "C:\Take-Screenshot.ps1"
 } 

Take-Screenshot.ps1 is in from here, but I’ve added the following to the bottom of the script to actually run the function.

Take-ScreenShot -screen -file C:\s.png -imagetype png 

After the screenshot is taken, I’ll copy it back to the host, but the problem is the picture is completely black.

I’m thinking this might be because the powershell is running the program, but there’s not session attached to it, so there really is not screen??

Leave a Reply

Your email address will not be published. Required fields are marked *