Use .NET’s System.Drawing.Graphics.CopyFromScreen method from PowerShell. Create a Bitmap, copy pixels from the display into it, and save the bitmap as a PNG. The script below captures the primary monitor, writes a timestamped file in your Pictures folder, and disposes its graphics objects even when saving fails.
Capture the primary display as a PNG
This Windows desktop example uses Windows Forms to obtain the primary screen bounds and System.Drawing to copy the pixels. Microsoft defines CopyFromScreen as a bit-block transfer of color data from a screen rectangle to a Graphics drawing surface.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$bounds = $screen.Bounds
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen(
$bounds.Location,
[System.Drawing.Point]::Empty,
$bounds.Size
)
$pictures = [Environment]::GetFolderPath('MyPictures')
if ([string]::IsNullOrWhiteSpace($pictures)) {
$pictures = $env:TEMP
}
$fileName = 'screenshot-{0}.png' -f (Get-Date -Format 'yyyyMMdd-HHmmss')
$path = Join-Path $pictures $fileName
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
Write-Output $path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
Run it in an interactive PowerShell window. The final line prints the complete path, for example C:UsersyouPicturesscreenshot-20260929-143012.png. PNG is lossless and is a sensible default for text, application windows and diagrams.
What each part of the script does
Load the required assemblies
Add-Type -AssemblyName System.Windows.Forms exposes screen information. Add-Type -AssemblyName System.Drawing supplies Bitmap, Graphics and image formats. These are Windows desktop APIs; do not assume the same code works unchanged on every PowerShell edition or operating system.
Recommended Free Tools
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Define the capture rectangle
PrimaryScreen.Bounds supplies the primary display’s location, width and height. CopyFromScreen receives a source point, a destination point inside the bitmap, and a Size. The bitmap must be at least as large as that size.
Release unmanaged resources
Graphics and Bitmap wrap native resources. The finally block disposes both objects whether the copy and save succeed or throw an exception. This prevents repeated captures from accumulating handles and memory.
Capture a selected rectangle
For a fixed region, replace the screen bounds with explicit screen coordinates. Coordinates are measured in screen pixels relative to the virtual desktop origin.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Add-Type -AssemblyName System.Drawing
$left = 200
$top = 120
$width = 900
$height = 600
$bitmap = New-Object System.Drawing.Bitmap $width, $height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$source = New-Object System.Drawing.Point $left, $top
$destination = [System.Drawing.Point]::Empty
$size = New-Object System.Drawing.Size $width, $height
$graphics.CopyFromScreen($source, $destination, $size)
$path = Join-Path $env:TEMP 'powershell-region.png'
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
$path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
Use this form when the application window or dashboard always occupies a known area. If a window moves or changes size, discover its bounds first or use an interactive selection tool rather than hard-coding coordinates.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Capture more than one monitor
To capture the entire desktop, use the virtual-screen rectangle rather than PrimaryScreen.Bounds. This includes monitors arranged to the left or above the primary display, so the virtual origin can have negative coordinates.
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$bounds = [System.Windows.Forms.SystemInformation]::VirtualScreen
$bitmap = New-Object System.Drawing.Bitmap $bounds.Width, $bounds.Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen($bounds.Left, $bounds.Top, 0, 0, $bounds.Size)
$path = Join-Path $env:TEMP 'virtual-desktop.png'
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
$path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
Display arrangements, scaling and mixed-DPI settings can affect how coordinates map to pixels. Verify the result on the exact Windows and .NET configuration you intend to automate; broad behavior across PowerShell 5.1, PowerShell 7, modern .NET, and every multi-monitor arrangement is not guaranteed by this example.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Choose another output format
Change the file extension and encoder passed to Save:
- PNG:
[System.Drawing.Imaging.ImageFormat]::Pngfor lossless text and interface captures. - JPEG:
[System.Drawing.Imaging.ImageFormat]::Jpegfor smaller photographic images, with some compression loss. - BMP:
[System.Drawing.Imaging.ImageFormat]::Bmpwhen an uncompressed bitmap is required.
Do not rely on the filename extension alone. The encoder supplied to Save determines the actual image format.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Automate repeated captures
Loop in an interactive session
Wrap the capture in a function and call it on a timer. Keep the resource creation and disposal inside the function so each iteration starts cleanly.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
function Save-ScreenShot {
param([string]$Path)
$bounds = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$bitmap = New-Object System.Drawing.Bitmap $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)
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
}
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$dir = Join-Path $env:TEMP 'screen-captures'
New-Item -ItemType Directory -Path $dir -Force | Out-Null
for ($i = 0; $i -lt 10; $i++) {
$name = 'capture-{0}.png' -f (Get-Date -Format 'yyyyMMdd-HHmmssfff')
Save-ScreenShot (Join-Path $dir $name)
Start-Sleep -Seconds 30
}
Use Task Scheduler carefully
A scheduled task using this technique needs an interactive desktop. Configure the task to run only when the user is logged on. A task running non-interactively as SYSTEM has no visible desktop screen to copy. This is guidance from a Microsoft Q&A accepted answer, not a promise that every Windows configuration behaves identically.
- Save the script at a stable path, such as
C:Scriptscapture.ps1. - In Task Scheduler, create a task and set the trigger interval.
- On General, select Run only when user is logged on.
- On Actions, launch
powershell.exe(Windows PowerShell) with-NoProfile -ExecutionPolicy Bypass -File C:Scriptscapture.ps1, subject to your organization’s execution-policy rules. - Test while the target user is logged in and the display is unlocked.
Limitations and edge cases
- Locked or secure desktops: The API copies the desktop available to the process. Secure sign-in screens, elevation prompts and other protected surfaces may not be capturable.
- Protected video: DRM-protected or hardware-overlay content can appear black or incomplete.
- Cursor: The bitmap contains screen pixels; cursor inclusion is not established by the basic method. If the pointer matters, test your target environment and use a separate cursor-drawing approach.
- Visibility: Minimized, occluded or off-screen windows are not rendered as visible pixels for this kind of desktop capture.
- Permissions and failures:
CopyFromScreencan raise aWin32Exception. Check the source rectangle, display state and execution context before retrying. - PowerShell edition: Confirm that the required Windows desktop assemblies are available in the host you deploy. Do not assume Windows-only APIs provide a portable solution on non-Windows systems.
Troubleshoot common errors
| Symptom | Likely cause | Fix |
|---|---|---|
Unable to find type [System.Windows.Forms.Screen] |
The assembly was not loaded or the host lacks Windows Forms. | Run Add-Type -AssemblyName System.Windows.Forms and verify you are using a Windows desktop-capable PowerShell installation. |
Parameter is not valid while saving |
The destination directory does not exist, the file is locked, or the encoder/path is invalid. | Create the directory first, choose a new filename, and pass an explicit ImageFormat. |
| The image is black or incomplete | Protected content, a secure desktop, an overlay, or an incorrect capture context. | Test with an ordinary desktop window while logged in and unlocked; protected surfaces may not be capturable. |
| Scheduled file is missing | The task ran without an interactive desktop or under a different account. | Select Run only when user is logged on, use an absolute output path, and inspect Task Scheduler history. |
| Only one monitor appears | The script uses PrimaryScreen.Bounds. |
Use SystemInformation.VirtualScreen and test coordinates with your monitor arrangement. |
Or skip the browser setup
If what you really need is a screenshot of a website rather than the pixels on your Windows desktop, ScreenshotNeo returns a PNG, JPEG, WebP or PDF from one request. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets; each step can be disabled. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and response headers report the page verdict and billing status.
See the ScreenshotNeo API documentation for all options. A cURL request is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
The equivalent Python call is:
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)
In 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}`);
ScreenshotNeo also provides an MCP server with take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients. Features include full-page lazy-image loading, CSS-selector element capture, device presets, custom JavaScript and CSS, waits, request blocking, authentication headers and cookies, geolocation, PDF controls, signed links, asynchronous webhooks, bulk capture of up to 100 URLs per call, caching with a chosen TTL, and a usage API.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000/month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing provides two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots a month with no card.
PowerShell screenshot checklist
- Run on a Windows desktop host with the required assemblies.
- Choose primary, virtual-desktop or explicit region bounds.
- Create a bitmap that matches the requested width and height.
- Call
CopyFromScreenand save with an explicit encoder. - Dispose
GraphicsandBitmapin afinallyblock. - For scheduled work, require an interactive logged-on session.
- Test protected content, scaling and monitor layouts on the deployment machine.
Frequently Asked Questions
Can I capture a browser page without capturing the whole desktop?
Not with CopyFromScreen alone; it copies a screen rectangle. Use a browser automation or website screenshot service when you need page rendering independent of window position.
Why does my output have a different pixel size than the monitor resolution?
Windows display scaling and mixed-DPI monitor arrangements can change coordinate and bitmap behavior. Measure the resulting file on the target machine instead of assuming logical dimensions equal physical pixels.
Free tools Windows power users keep installed
One-click scans. No signup required.
Is PowerShell required for ScreenshotNeo?
No. ScreenshotNeo is an HTTP API; use the cURL, Python or Node.js examples, or its MCP server from a compatible AI client.
Quick Recap
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.

