Take the 2-minute tour ×

How can I capture the screen in Windows PowerShell? I need to be able to save the screen to disk.

share|improve this question

3 Answers 3

up vote 17 down vote accepted

You can also use .NET to take the screenshot programatically (which gives you finer control):

   $bmp = New-Object Drawing.Bitmap $bounds.width, $bounds.height




$bounds = [Drawing.Rectangle]::FromLTRB(0, 0, 1000, 900)
screenshot $bounds "C:\screenshot.png"
share|improve this answer
Great - how hard would it be to get this to capture the window of a specific application ? I am creating an IE instance like this : $ie = new-object -com "InternetExplorer.Application" - would it be possible to capture just the output of this window for instance ? –  monojohnny Mar 14 '13 at 12:04

This PowerShell function will capture the screen in PowerShell and save it to an automatically numbered file. If the -OfWindow switch is used, then the current window will be captured.

This works by using the built in PRINTSCREEN / CTRL-PRINTSCREEEN tricks, and it uses a bitmap encoder to save the file to disk.

function Get-ScreenCapture

    begin {
        Add-Type -AssemblyName System.Drawing
        $jpegCodec = [Drawing.Imaging.ImageCodecInfo]::GetImageEncoders() | 
            Where-Object { $_.FormatDescription -eq "JPEG" }
    process {
        Start-Sleep -Milliseconds 250
        if ($OfWindow) {            
        } else {
        Start-Sleep -Milliseconds 250
        $bitmap = [Windows.Forms.Clipboard]::GetImage()    
        $ep = New-Object Drawing.Imaging.EncoderParameters  
        $ep.Param[0] = New-Object Drawing.Imaging.EncoderParameter ([System.Drawing.Imaging.Encoder]::Quality, [long]100)  
        $screenCapturePathBase = "$pwd\ScreenCapture"
        $c = 0
        while (Test-Path "${screenCapturePathBase}${c}.jpg") {
        $bitmap.Save("${screenCapturePathBase}${c}.jpg", $jpegCodec, $ep)

Hope this helps

share|improve this answer
Are there additional steps needed to get this to work on Windows 7 ? I'm getting the following error when running the function:"Unable to find type [Windows.Forms.Sendkeys]: make sure that the assembly containing this type is loaded." and then a further error "Unable to find type [Windows.Forms.Clipboard]: make sure that the assembly containing this type is loaded." , and then one more error (but I think because the previous two calls failed). –  monojohnny Mar 21 at 17:06
You probably haven't loaded Winforms. I'd recommend you simply download the module this answer is now in: RoughDraft –  Start-Automating Mar 24 at 22:29

Microsoft have a Powershell script available here:


I have just tried it on a Windows 7 machine and it to work, using the commandline example provided:

Take-ScreenShot -screen -file "C:\image.png" -imagetype png 
share|improve this answer
Where do you place this .ps1 file so you don't have to type the entire network path in ? –  Aaron Aug 27 at 13:40
@Aaron, not quite sure how best to do this - but probably set it in Powershell profile (perhaps either by editing PATH variable, or using an alias) : this article may help :stackoverflow.com/questions/714877/… –  monojohnny Sep 2 at 15:07

Your Answer


