Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Windows, take a PowerShell screenshot with System.Drawing by creating a Bitmap, copying pixels into it with Graphics.CopyFromScreen, and saving the bitmap. The script below captures the primary display as a PNG, disposes its graphics resources safely, and can be adapted to any screen rectangle.

Capture the primary screen

Run this in Windows PowerShell 5.1 or PowerShell 7 on Windows. It loads the drawing and Windows Forms assemblies, reads the primary display bounds, creates a bitmap of the same size, copies the screen pixels, and writes a PNG file.

param(
    [string]$Path = (Join-Path (Get-Location) 'screen.png')
)

Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName System.Windows.Forms

$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$bitmap = [System.Drawing.Bitmap]::new($bounds.Width, $bounds.Height)
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)

try {
    $graphics.CopyFromScreen(
        $bounds.Location,
        [System.Drawing.Point]::Empty,
        $bounds.Size
    )

    $bitmap.Save($Path, [System.Drawing.Imaging.ImageFormat]::Png)
    Write-Host "Saved screenshot to $Path"
}
finally {
    $graphics.Dispose()
    $bitmap.Dispose()
}

Save it as Capture-Screen.ps1, then run:

.apture-Screen.ps1[ -Path 'C:Tempscreen.png'

The CopyFromScreen call performs a bit-block transfer of color data from the screen to the Graphics surface, as documented in the Microsoft Learn API reference. It does not create a file by itself; the subsequent Bitmap.Save call does that.

Capture a selected rectangle

A screenshot is a rectangle defined by a source point and a size. Set the rectangle explicitly when you need a window area, a toolbar, or a fixed region rather than the whole primary display.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
param(
    [int]$X = 100,
    [int]$Y = 100,
    [int]$Width = 1200,
    [int]$Height = 800,
    [string]$Path = (Join-Path (Get-Location) 'region.png')
)

Add-Type -AssemblyName System.Drawing

$source = [System.Drawing.Point]::new($X, $Y)
$size = [System.Drawing.Size]::new($Width, $Height)
$bitmap = [System.Drawing.Bitmap]::new($size.Width, $size.Height)
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)

try {
    $graphics.CopyFromScreen(
        $source,
        [System.Drawing.Point]::Empty,
        $size
    )

    $bitmap.Save($Path, [System.Drawing.Imaging.ImageFormat]::Png)
    Write-Host "Saved $Width x $Height pixels from ($X, $Y) to $Path"
}
finally {
    $graphics.Dispose()
    $bitmap.Dispose()
}

For example, .apture-Region.ps1[ -X 0 -Y 0 -Width 800 -Height 600 copies the rectangle whose top-left corner is (0, 0). Coordinates are desktop coordinates, not coordinates relative to the bitmap. A monitor positioned to the left or above the primary display can therefore have negative X or Y values.

Understand the capture pipeline

1. Load the required assemblies

Add-Type -AssemblyName System.Drawing provides Bitmap, Graphics, and image formats. System.Windows.Forms is used in the full-screen example only to obtain Screen.PrimaryScreen.Bounds. If you already know the rectangle, the selected-region script needs only System.Drawing.

2. Choose source coordinates and size

CopyFromScreen receives a source location, a destination location inside the bitmap, and a Size. Using Point.Empty as the destination starts writing at the bitmap’s upper-left corner. The source location and size must describe the part of the desktop you actually want.

3. Allocate the bitmap and graphics object

The bitmap dimensions determine the output dimensions. Graphics.FromImage($bitmap) gives GDI+ a drawing surface to receive the copied pixels.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

4. Save with an explicit format

Pass an ImageFormat instead of relying on a filename extension. PNG is useful for text and interface screenshots because it preserves lossless pixels. GDI+ also documents BMP, GIF, EXIF, JPEG, and TIFF formats; select one deliberately when your consumer requires it.

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

5. Dispose resources

The finally block runs whether capture and saving succeed or fail. Disposing both Graphics and Bitmap releases their native resources and avoids leaving handles open in a long-running script.

Choose another display or an arbitrary monitor layout

PrimaryScreen is only one display. Enumerate [System.Windows.Forms.Screen]::AllScreens and inspect each screen’s bounds before selecting one.

Add-Type -AssemblyName System.Windows.Forms

[System.Windows.Forms.Screen]::AllScreens |
    Select-Object DeviceName, Primary, Bounds

After identifying a device, use its Bounds in the same capture pattern:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
$screen = [System.Windows.Forms.Screen]::AllScreens |
    Where-Object { $_.DeviceName -eq '\.DISPLAY2' }

if ($null -eq $screen) {
    throw 'The requested display was not found.'
}

$bounds = $screen.Bounds
$bitmap = [System.Drawing.Bitmap]::new($bounds.Width, $bounds.Height)
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)

try {
    $graphics.CopyFromScreen($bounds.Location, [System.Drawing.Point]::Empty, $bounds.Size)
    $bitmap.Save('C:Tempdisplay2.png', [System.Drawing.Imaging.ImageFormat]::Png)
}
finally {
    $graphics.Dispose()
    $bitmap.Dispose()
}

Do not assume that a virtual desktop starts at (0, 0). In a multi-monitor arrangement, the bounds can extend into negative coordinates. Capture the exact Location and Size returned by the selected Screen object.

Save JPEG or another GDI+ format

Change the format argument while keeping the capture code unchanged:

Rank #3
Sale
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
$bitmap.Save('C:Tempscreen.jpg', [System.Drawing.Imaging.ImageFormat]::Jpeg)
# Other documented choices include Bmp, Gif, Exif and Tiff.

Keep the filename extension and the format argument consistent. If a receiving application expects PNG, continue to pass ImageFormat.Png even when the path is assembled dynamically.

PowerShell and .NET version limits

Environment What to expect Practical guidance
Windows PowerShell 5.1 Runs on the .NET Framework and is Windows-specific. Use the scripts as shown and confirm the assemblies are available on the machine.
PowerShell 7.x on Windows Runs on modern .NET; System.Drawing.Common is supported on Windows. Use a Windows PowerShell session and verify the installed runtime if assembly loading fails.
PowerShell 7.x on macOS or Linux PowerShell itself is cross-platform, but Microsoft documents System.Drawing.Common as Windows-only in .NET 6 and later. Do not treat this recipe as a portable desktop-capture solution; use a platform-appropriate library instead.

Microsoft’s Bitmap documentation states that, in .NET 6 and later, the System.Drawing.Common package is supported only on Windows. Microsoft’s overview of differences between Windows PowerShell 5.1 and PowerShell 7.x explains why the host version matters.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Make the script safer for repeated use

Validate dimensions and create the destination folder

if ($Width -le 0 -or $Height -le 0) {
    throw 'Width and Height must be positive integers.'
}

$directory = Split-Path -Parent $Path
if ($directory -and -not (Test-Path -LiteralPath $directory)) {
    New-Item -ItemType Directory -Path $directory -Force | Out-Null
}

Place these checks before constructing the bitmap. A zero or negative size is an input error, not a screen-capture failure.

Prevent accidental overwrites

Use Test-Path and choose a new name, or write to a temporary file and move it into place after Save succeeds. A destination file that is open in another program can cause the save operation to fail.

Keep capture and file I/O separate

Capture first, then save inside the same try block. If a scheduled job needs to process the image, close the bitmap before handing the path to another process; the finally block guarantees that cleanup occurs.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient

Troubleshoot common failures

Symptom Likely cause Fix
Add-Type cannot load an assembly The session is not running on Windows, the required runtime is missing, or the assembly name is unavailable in that edition. Check $PSVersionTable, confirm Windows, and verify the installed .NET/PowerShell runtime. On non-Windows PowerShell 7, use another capture library.
CopyFromScreen throws Win32Exception The API reports this exception when the screen operation fails; the exact cause depends on the desktop and display context. Check that the source rectangle is valid, the target display is active, and the process is running in an interactive Windows desktop session.
The image shows the wrong monitor The script used PrimaryScreen or coordinates relative to the wrong display. Inspect AllScreens, select the intended Bounds, and use its location and size.
The crop is offset or clipped The source point, width, or height does not match the desktop coordinate system. Print the chosen coordinates, account for negative multi-monitor coordinates, and reduce the rectangle to a known visible area.
The file is missing or cannot be opened The directory does not exist, the process lacks write permission, or another process has the file open. Use an absolute writable path, create the directory first, and choose a new filename.
A scheduled task captures a blank or unexpected desktop Services and unattended tasks may not have the same interactive desktop as a logged-in user. Test in the exact account and session used by the task. Do not assume an unattended process can see an interactive user’s display.

Microsoft’s CopyFromScreen reference specifically documents Win32Exception when the operation fails. It does not promise identical behavior for remote sessions, services, scheduled tasks, DPI-scaling configurations, or every multi-monitor arrangement, so validate those deployment conditions on the target machine.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a browser screenshot is the real requirement

System.Drawing captures the pixels visible in a Windows desktop session. It is not a browser renderer: it will not open a URL, wait for page resources, accept a cookie banner, or produce a full-page capture of content below the viewport. For automated website images or PDFs, ScreenshotNeo is the first service to try because it removes consent banners, popups, and chat widgets before capture, bills only clean shots, and has a $5 paid plan.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

ScreenshotNeo provides a GET endpoint that returns a PNG, JPEG, WebP, or PDF for a URL. The API can wait for a selector, delay, or network idle; load lazy images for full-page captures; select an element by CSS selector; set a viewport, device preset, dark mode, retina scale, timezone, geolocation, headers, cookies, user agent, or authorization; run custom CSS or JavaScript; click or hide elements; block ads, trackers, requests, or resource types; resize images; cache with a chosen TTL; create signed image links; submit asynchronous jobs with signed webhooks; capture up to 100 URLs per bulk call; and expose usage data and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs.

Use the one-call endpoint documented at ScreenshotNeo’s documentation:

PowerShell

$q = @{
    access_key = 'YOUR_API_KEY'
    url        = 'https://stripe.com'
}
Invoke-WebRequest -Uri 'https://api.screenshotneo.com/v1/shot' -Body $q -OutFile 'shot.webp'

cURL

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Python

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before the shot; each cleanup step can be disabled.
  • Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed. Response headers report the page verdict and whether it was billed.
  • An MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card. Paid plans start at $5 for 3,000 shots; every feature is available on every plan, and annual billing provides two months free.

Create a free ScreenshotNeo account to use the 1,000 monthly screenshots without adding a card.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

FAQ

Does CopyFromScreen capture a minimized or hidden window?

No. It copies pixels currently available from the desktop drawing surface. Bring the desired content into the visible capture rectangle or use an application-specific automation approach.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Can I capture only one application by passing its window title?

Not with CopyFromScreen alone. The method accepts screen coordinates and a size; obtaining a window rectangle requires separate Windows window-management code.

Why is my high-DPI screenshot a different size than expected?

DPI awareness and display scaling affect the coordinates and bounds reported by the Windows session. Check the actual Screen.Bounds values on the machine where the script runs rather than assuming physical-pixel dimensions.

Frequently Asked Questions

Does CopyFromScreen capture a minimized or hidden window?

No. It copies pixels currently available from the desktop drawing surface; the content must be visible in the capture rectangle.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Can I capture only one application by passing its window title?

Not with CopyFromScreen alone. It accepts screen coordinates and a size, so window-specific capture requires separate Windows window-management code.

Why is my high-DPI screenshot a different size than expected?

DPI awareness and display scaling affect reported coordinates and bounds. Inspect Screen.Bounds on the target machine instead of assuming physical-pixel dimensions.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.