How to take the screenshot of particular folder using powershell


Can you please guide as how to take sceenshot of any particular folder(i.e. C:/Program Files/…)


In Windows, you can press 'PRTSC" to copy multiple screens and paste with CTRL + V into mspaint.

Welcome to the forum. :wave:t4:

We actually expect you to make an own attempt at the first place to get your task done or to solve your problem. This forum is for scripting questions rather than script requests. We do not write customized and ready to use scripts or solutions on request.

And as @random-commandline already mentioned you can use the default keyboard shortcuts to create screenshots. For example with <Win>+<PrintScreen> you create a screenshot of the complete desktop and save it automatically in the “pictures” folder of your profile. :wink:

I tried below script but with this I am able to take the screenshot of desktop only. But I required for particular folder .

Invoke-Item C:\Automation
$File = 'C:\Automation\filename.png'
Add-Type -AssemblyName System.Windows.Forms
Add-type -AssemblyName System.Drawing
# Gather Screen resolution information
$Screen = [System.Windows.Forms.SystemInformation]::VirtualScreen
$Width = $Screen.Width
$Height = $Screen.Height
$Left = $Screen.Left
$Top = $Screen.Top
# Create bitmap using the top-left and bottom-right bounds
$bitmap = New-Object System.Drawing.Bitmap $Width, $Height
# Create Graphics object
$graphic = [System.Drawing.Graphics]::FromImage($bitmap)
# Capture screen
$graphic.CopyFromScreen($Left, $Top, 0, 0, $bitmap.Size)
# Save to file
$bitmap.Save($File, [System.Drawing.Imaging.ImageFormat]::Png)

Could you please go back, edit your last reply and fix the formatting of the code?

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in <---- Click :point_up_2:t4: :wink:

Thanks in advance.

May I ask whatfor you need the screenshot? When you say you need the screenshot " for particular folder ." it sounds for like it would be easier to have listing of the contained files and folders of a particular folder.

No, Iisting will not help. The requirement is to take screenshot of the files available in the folder as part of the evidence collection for deployment activities. But the problem comes in taking for the folders where we have to scroll to take the screenshot for all files available in that folder. With above mentioned script, I am able to take the screenshot of the files in a folder but not able to scroll.

I cannot help you with that. Sorry. :man_shrugging:t4:

But depending on the amount of files and the size of the used font and the size of the window and the configuration of the view of the explorer (small icons, extra large icons or details or whatever) it might be enough to have one screenshot showing all desired files without the need for scrolling. :wink:

And BTW:

That sounds really really weird to me? What kind of evidence should this be?

That sounds like a lot of error prone effort for a very little benefit. :wink:

1 Like

I have to agree with Olaf, a picture would be useless for further processing/interrogation not to mention all the information the screenshot wouldn’t get like createdtime, lastaccesstime, owner, permissions, etc.

I say run Get-ChildItem for the folder in question, select the data you need (name, length, lastwritetime, etc) and use that data as a report.