Use .NET’s System.Drawing.Graphics.CopyFromScreen from PowerShell. It copies pixels from a screen rectangle into a bitmap, which you can save as PNG, JPEG, or another supported format. The script below captures the primary display, creates a timestamped PNG in your temporary folder, and releases its graphics resources even if saving fails.
Capture the primary display
Run this in Windows PowerShell or a PowerShell host that supports the Windows desktop APIs:
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$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
)
$path = Join-Path $env:TEMP ("screenshot-{0:yyyyMMdd-HHmmss}.png" -f (Get-Date))
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
Write-Output $path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
The command prints the complete file path after a successful save. Open it with Invoke-Item $path, or copy it elsewhere with Copy-Item. PNG is lossless and a sensible default for text, application windows, and diagrams.
Microsoft documents CopyFromScreen as performing “a bit-block transfer of color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics.” The bitmap is that drawing surface; the source point and size determine which pixels are copied.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
- 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
What each part of the script does
Load the Windows assemblies
System.Windows.Forms supplies screen information such as PrimaryScreen.Bounds. System.Drawing supplies Bitmap, Graphics, and image encoders. Add-Type loads those assemblies for the current session.
Choose a source rectangle
$bounds.Location is the upper-left source coordinate and $bounds.Size is its width and height. The destination point is Point.Empty, so pixels are written from the top-left of the new bitmap.
Save and clean up
Bitmap.Save writes the image using the selected encoder. The finally block disposes both .NET objects, preventing handles and memory from accumulating during repeated captures.
Capture a selected rectangle
For a fixed region, replace the screen bounds with explicit coordinates and dimensions. Coordinates are desktop pixels; the origin and any negative values depend on your monitor arrangement.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallAdd-Type -AssemblyName System.Drawing
$x = 100
$y = 80
$width = 1200
$height = 700
$bitmap = New-Object System.Drawing.Bitmap $width, $height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen(
$x,
$y,
0,
0,
[System.Drawing.Size]::new($width, $height)
)
$path = Join-Path $env:USERPROFILE 'Picturesregion.png'
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
$path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
Make sure the rectangle lies within the visible desktop area. An invalid or inaccessible source can cause a .NET or Windows graphics exception rather than producing a useful image.
Capture every monitor in the virtual desktop
To include all attached displays, select the screen object marked as the primary screen and combine the monitor rectangles into one virtual bounding rectangle. This preserves negative coordinates when a monitor sits left or above the primary display.
Rank #2
- 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
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
$screens = [System.Windows.Forms.Screen]::AllScreens
$left = ($screens | ForEach-Object { $_.Bounds.Left } | Measure-Object -Minimum).Minimum
$top = ($screens | ForEach-Object { $_.Bounds.Top } | Measure-Object -Minimum).Minimum
$right = ($screens | ForEach-Object { $_.Bounds.Right } | Measure-Object -Maximum).Maximum
$bottom = ($screens | ForEach-Object { $_.Bounds.Bottom } | Measure-Object -Maximum).Maximum
$width = $right - $left
$height = $bottom - $top
$bitmap = New-Object System.Drawing.Bitmap $width, $height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen(
[System.Drawing.Point]::new($left, $top),
[System.Drawing.Point]::Empty,
[System.Drawing.Size]::new($width, $height)
)
$path = Join-Path $env:USERPROFILE 'Picturesvirtual-desktop.png'
$bitmap.Save($path, [System.Drawing.Imaging.ImageFormat]::Png)
$path
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
The resulting image is rectangular. If the monitors have different sizes or positions, unused areas between them can appear as background-colored gaps. Test the bounds on the exact multi-monitor and DPI configuration you support.
Choose PNG, JPEG, or another format
Pass a different encoder to Save and use a matching extension:
| Format | PowerShell expression | Use it when |
|---|---|---|
| PNG | [System.Drawing.Imaging.ImageFormat]::Png |
You need sharp text and lossless output. |
| JPEG | [System.Drawing.Imaging.ImageFormat]::Jpeg |
A smaller photographic image is more important than perfect text. |
| BMP | [System.Drawing.Imaging.ImageFormat]::Bmp |
You need an uncompressed bitmap and can accept a large file. |
For JPEG quality control, create an encoder and set its quality property rather than relying on the default. PNG generally avoids that extra configuration.
Run a reusable screenshot function
A function makes repeated or scheduled captures easier and lets callers choose the output path and rectangle.
function Save-ScreenCapture {
param(
[Parameter(Mandatory)] [string] $Path,
[int] $X = $null,
[int] $Y = $null,
[int] $Width = $null,
[int] $Height = $null
)
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
if ($null -eq $Width -or $null -eq $Height) {
$source = [System.Windows.Forms.Screen]::PrimaryScreen.Bounds
$X = $source.Left; $Y = $source.Top
$Width = $source.Width; $Height = $source.Height
}
$folder = Split-Path -Parent $Path
if ($folder -and -not (Test-Path $folder)) {
New-Item -ItemType Directory -Path $folder -Force | Out-Null
}
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
$graphics = [System.Drawing.Graphics]::FromImage($bitmap)
try {
$graphics.CopyFromScreen($X, $Y, 0, 0,
[System.Drawing.Size]::new($Width, $Height))
$bitmap.Save($Path, [System.Drawing.Imaging.ImageFormat]::Png)
}
finally {
$graphics.Dispose()
$bitmap.Dispose()
}
}
Save-ScreenCapture -Path (Join-Path $env:USERPROFILE 'Picturescapture.png')
Use an absolute path for unattended jobs. A relative path is resolved from the process’s working directory, which may differ between an interactive shell and Task Scheduler.
Schedule automatic captures
The capture API needs an interactive desktop. Configure a scheduled task to run only when the target user is logged on; a task running as noninteractive SYSTEM has no desktop screen to copy. This is guidance from a Microsoft Q&A answer, not a guarantee for every Windows configuration.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- 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.
- Save your script, for example as
C:Scriptscapture.ps1. - Open Task Scheduler and choose Create Task.
- On General, select the user account and choose Run only when user is logged on.
- On Triggers, add the schedule or event that should start the capture.
- On Actions, select Start a program. Use
powershell.exefor Windows PowerShell, or the full path topwsh.exefor PowerShell 7. Add arguments such as-NoProfile -ExecutionPolicy Bypass -File "C:Scriptscapture.ps1". - On Conditions, remove power or idle restrictions that would prevent the required run.
- Run the task manually once while logged on and inspect the output directory and Task Scheduler history.
Compatibility and capture limitations
- This is Windows desktop code. The available material does not establish a complete compatibility matrix for Windows PowerShell 5.1, PowerShell 7, modern .NET, or non-Windows systems, so verify the exact host you deploy.
- Secure desktops, protected video, remote sessions, mixed-DPI monitors, and cursor inclusion can behave differently. Test those cases rather than promising that ordinary desktop capture will include them.
- The API can report a
Win32Exception. Record the host, coordinates, dimensions, and account when diagnosing one. - Large, high-resolution bitmaps consume memory proportional to width × height × color depth. Capture only the region you need for frequent jobs, and dispose objects after every image.
Troubleshooting
“Unable to find type” or missing assembly errors
Run the two Add-Type lines before creating screen or drawing objects. If the host is not Windows desktop-capable, this API is the wrong capture method; use a platform-appropriate tool instead.
The file is created but black or blank
Confirm that a user is logged on and the desktop is unlocked and visible. A noninteractive scheduled task, secure desktop, protected content, or remote-session policy can prevent ordinary pixels from being available.
Only one monitor appears
PrimaryScreen.Bounds intentionally captures one display. Use AllScreens and the virtual-desktop function for a combined image, or pass the coordinates of the specific monitor you want.
The image is cropped or shifted
Print the chosen rectangle and compare it with each monitor’s Bounds. Negative coordinates are normal when a monitor is positioned left or above the primary display. Mixed scaling requires validation on the actual machine.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →The scheduled task works manually but not on a timer
Check that the task uses the same account, executable, script path, working directory, and “Run only when user is logged on” setting as your successful manual test. Review Task Scheduler history and write errors to a log file.
Repeated captures slow down or exhaust memory
Dispose Graphics and Bitmap in a finally block, avoid unnecessarily large rectangles, and stagger captures instead of starting many simultaneous PowerShell processes.
Rank #4
- 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
Or skip the browser setup
If what you really need is a screenshot of a public web page rather than the pixels on your Windows desktop, ScreenshotNeo makes one GET request and returns PNG, JPEG, WebP, or PDF. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets. Bot checks, CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status.
See the parameter reference in the ScreenshotNeo documentation. The same endpoint can be called from PowerShell with Invoke-WebRequest:
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches$uri = 'https://api.screenshotneo.com/v1/shot?access_key=YOUR_API_KEY&url=https%3A%2F%2Fstripe.com'
Invoke-WebRequest -Uri $uri -OutFile 'shot.webp'
Equivalent requests are useful in mixed-language automation:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
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. Every plan includes its features; the Free plan includes 1,000 shots per month with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
FAQ
Can this capture the mouse pointer?
The documented CopyFromScreen operation copies screen pixels; the available material does not establish guaranteed cursor inclusion. If the pointer matters, test the exact Windows configuration and consider a separate cursor-rendering step.
Can I capture a minimized window?
This method captures the visible desktop rectangle, not an off-screen or minimized window’s render surface. Bring the target content onto the visible desktop or use an application-specific automation API.
Where should I store screenshots from a long-running job?
Use a dedicated directory with an absolute path, a predictable naming scheme, and a retention policy. Ensure the task account has write permission and monitor disk usage.
Best Value
- 【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.
Is PowerShell required for ScreenshotNeo?
No. ScreenshotNeo is an HTTP API, so any language or shell that can make a GET request can use it; the PowerShell, cURL, Python, and Node.js examples above all call the same endpoint.
Frequently Asked Questions
Can this capture the mouse pointer?
The documented CopyFromScreen operation copies screen pixels; guaranteed cursor inclusion is not established, so test your configuration or add a separate cursor-rendering step.
Can I capture a minimized window?
No. The method captures visible desktop pixels, not a minimized window’s off-screen render surface.
Where should I store screenshots from a long-running job?
Use an absolute, writable directory, predictable names, and retention controls so disk usage remains bounded.
Is PowerShell required for ScreenshotNeo?
No. It is an HTTP API usable from PowerShell, cURL, Python, Node.js, or another HTTP 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.




