This script has a function that allows you to take a screenshot of the entire desktop or of an active window. Also includes option to save the screenshot to a file.

10,511 times
Add to favorites
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question

  • Need a little more functionality added to it
    1 Posts | Last post March 26, 2016
    • Hi Boe,
      I need something similar to this, where it will take a screenshot of an active window and open an new email with the screenshot pasted. Is it possible ?
  • How do I use this?
    2 Posts | Last post February 04, 2016
    • I'm new so how do I use this? I downloaded it but where do I put it? I tried to drag it onto powershell and do a command but it said I had restriction.
    • See my comment from today on the first question.
  • Not working for me
    7 Posts | Last post February 04, 2016
    • I'm not getting an error message but I'm not getting an image either. I'm on Win 7 Pro and PowerShell ISE 3.0. I'm in the same directory (c:\temp) and execution-policy is unrestricted. Any ideas on what else I might be missing?
    • I am getting the same issue, rodchar.  The only difference for me is that I am on Win7 Home
    • I'll have to take a look at this. I honestly have not touched this script in a couple years so I have no doubt that there is something crazy happening.
    • @ Boe Prox : Any update ,since I am also running via Win 7 Home and not getting the desired output.
    • It would be SO SWEET if someone could get this script working again for us novices.  I'm not sure how to debug it, but it executes fine and simply doesn't write out a screenshot.  My command-line appears below.
      powershell ./Get-ScreenCapture.ps1 -activewindow -file "C:\Users\clint.sulis\Desktop\WebShot" -imagetype jpeg
      Can you spend a little time on this for us Boe?
    • Hello, so now i have fix this script. And now it works for me. Here are my change.
      If you call the Script you need to define on of the two Parameter -screen or -activewindow otherwise it not function. And sorry for my broken english.....
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -activewindow (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png -screen (works)
      .\Take-ScreenShot.ps1 -file C:\temp\balbla02.png -imagetype png (dont works)    
      .\Take-ScreenShot.ps1 -activewindow OR -screen ( only display some information)
      - Change Line 51 and 56 with ParameterSetName = "",
      - change Line 61 with ParameterSetName = "file",
      - Delete Line 1 and 260
      - Replace Line 213-215 with this code:
      #region Import the Assemblies 
      $assm = (
      #User Add-Type to import the code
      Add-Type -TypeDefinition $code -ReferencedAssemblies $assm -Language CSharp
      Now it should work. if not tell me ....
    • This script defines a function, but does not call it. Maybe in a later version of powershell all the examples here would work, but none of them worked for me. Loading the script merely loads the function, but doesn't execute it. To execute from WITHIN powershell, run:
      . .\Take-Screenshot.ps1                <---- Notice the initial period, it is important
      Take-Screenshot -screen -file bla.bmp  <---- Now you are calling the function, don't use the .ps1 extension
      To call it all in one call from a command prompt (or scheduled task):
      powershell -ExecutionPolicy RemoteSigned -Command "& {. .\Take-Screenshot.ps1; Take-Screenshot -screen -file bla.bmp}"
  • Good Work
    8 Posts | Last post December 02, 2014
    • Thanks for posting this Boe, I have never seen PowerShell code that imports a chunk of C# b4. Doubly cool for posting something that VBScript can't do. 
    • Thanks for this script. 
      Is it possible to extend the script to send the screenshot directly to a printer? 
      I tested a few things but the only thing I could print was:
      Tag                  : 
      PhysicalDimension    : {Width=1456, Height=876}
      Size                 : {Width=1456, Height=876}
      Width                : 1456
      Height               : 876
      HorizontalResolution : 96
      VerticalResolution   : 96
      Flags                : 335888
      RawFormat            : [ImageFormat: b96b3caa-0728-11d3-9d7b-0000f81ef32e]
      PixelFormat          : Format32bppRgb
      Palette              : System.Drawing.Imaging.ColorPalette
      FrameDimensionsList  : {7462dc86-6180-4c7e-8e3f-ee7333a7a483}
      PropertyIdList       : {}
      PropertyItems        : {}
    • Yes, I actually do that in my password generator form script that is posted out here as well.  If I have time today, I will work to add that functionality into the script. Thanks for the feedback!
    • As requested, I added the ability to send the screen-shot directly to your default printer.
    • Thanks for the updated script, it is printing the image but the image don't scale to fit the paper automatically. 
      It would be great if this also can be included in the script.
      Thanks in advance.
    • I will take a look at the script and see what I can do about that.  Thanks!
    • Sorry for being eager, but do you plan to add the ability to scale the image to the paper? Thanks in advance.
    • try this :