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

PowerShell’s file cmdlets let you inspect, create, read, write, copy, move, and delete files and folders. For routine work, use Get-ChildItem to find items, New-Item to create them, Get-Content and Set-Content or Add-Content to handle text, and Copy-Item, Move-Item, or Remove-Item to manage them. The examples below use Windows paths; change them to match your system.

How PowerShell file cmdlets work

PowerShell cmdlets operate through providers. The FileSystem provider exposes files and directories, but many of the same item, path, and content cmdlet families also work with other providers. To work with files, pass a filesystem path such as C:Datareport.csv or a relative path such as ./report.csv.

Cmdlets return objects, not just formatted text. That makes it possible to filter results by properties such as a file’s size, then pass the selected items to another command. Microsoft’s overview of provider command families is in about_Core_Commands; filesystem-specific behavior is described in about_FileSystem_Provider.

List files and folders

Get-ChildItem lists items in a location. Without recursion, it lists direct children; use -Recurse to include items in subfolders. Add -File when you only want files, or -Directory when you only want folders.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
  • Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Get-ChildItem -Path C:Data
Get-ChildItem -Path C:Data -Recurse
Get-ChildItem -Path C:Data -Recurse -File

To include hidden and system items, add -Force. Use -Depth to limit how many directory levels recursion traverses, and a filter to narrow matching names:

Get-ChildItem -Path C:Data -Recurse -Depth 2 -Filter *.csv -Force

For a property-based condition, pipe the results to Where-Object. This example selects files larger than 1 MB:

Get-ChildItem C:Data -Recurse -File | Where-Object Length -gt 1MB

Get-Location displays the current location, and Set-Location changes it. Relative paths are resolved from that location. Use Test-Path to check whether a target path exists before acting on it.

Rank #2
Sale
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
  • Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.

Create files and folders

Use New-Item with -ItemType Directory for a folder or -ItemType File for an empty file:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
New-Item -Path C:TempReports -ItemType Directory
New-Item -Path C:TempReportsrun.txt -ItemType File

The meaning of -Force depends on the target: Microsoft’s examples note that it returns an existing folder rather than replacing it, while using it for an existing file overwrites that file. Do not add -Force unless that behavior is intended.

Read and write file contents

Get-Content reads text as lines by default. Use -Raw to return the file as one string, -Tail to read the last specified number of lines, and -TotalCount to limit the read to the first specified number of lines.

Rank #3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
  • Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
  • Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
  • To get set up, connect the portable hard drive to a computer for automatic recognition no software required
  • This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
  • The available storage capacity may vary.
Get-Content -Path .log.txt
Get-Content -Path .log.txt -Raw
Get-Content -Path .log.txt -Tail 50
Get-Content -Path .log.txt -TotalCount 20

For text files where encoding matters, specify -Encoding. For byte-oriented input, use -AsByteStream rather than treating the data as text.

Set-Content replaces a file’s existing contents; Add-Content appends to them. Both can create a file if the target does not exist.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Set-Content -Path .status.txt -Value 'Complete'
Add-Content -Path .status.txt -Value 'Next step'

Choose Set-Content when the new value should replace what is there, and Add-Content when the existing contents must remain and the new value should be added after them. Microsoft’s examples and parameters for these operations are in the Get-Content and Set-Content references.

Rank #4
Sale
Maxone 500GB Ultra Slim Portable External Hard Drive HDD USB 3.0 Compatible with PC, Laptop, Charcoal Grey
  • Ultra Slim and Sturdy Metal Design: Merely 0.4 inch thick. All-Aluminum anti-scratch model delivers remarkable strength and durability, keeping this portable hard drive running cool and quiet.
  • Compatibility: It is compatible with Microsoft Windows 7/8/10, and provides fast and stable performance for PC, Laptop.
  • Improve PC Performance: Powered by USB 3.0 technology, this USB hard drive is much faster than - but still compatible with - USB 2.0 backup drive, allowing for super fast transfer speed at up to 5 Gbit/s.
  • Plug and Play: This external drive is ready to use without external power supply or software installation needed. Ideal extra storage for your computer.
  • What's Included: Portable external hard drive, 19-inch(48.26cm) USB 3.0 hard drive cable, user's manual, 3-Year manufacturer warranty with free technical support service.

Copy or move files and folders

Use Copy-Item for a duplicate and Move-Item to relocate an item. Copying a directory tree requires -Recurse. A different destination filename also renames an item during a move.

Copy-Item -Path C:Datareport.csv -Destination C:Backupreport.csv
Copy-Item C:DataProject -Destination C:BackupProject -Recurse
Move-Item -Path C:Dataold.txt -Destination C:Dataarchive.txt

An existing destination may cause an operation to fail or require -Force, depending on the command and situation. Check the destination with Test-Path, and try the operation on a small sample before applying it to many items. See Microsoft’s Copy-Item and Move-Item references for command details.

Delete files and directory trees carefully

Remove-Item deletes an item. Add -Recurse to remove a directory and its contents:

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.
Best Value
Sale
YOTUO 500GB External Hard Drive, Portable Storage Expansion HDD, USB 3.0 & USB-C for PC, Mac, Desktop, Laptop, Smartphone, PS4, Xbox One, Xbox 360, Office & Game Black
  • 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
  • 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
  • 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
  • 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
  • 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.
Remove-Item -Path .old.log
Remove-Item -Path C:TempDeleteMe -Recurse

Without -Recurse, removing a directory that contains children can prompt for confirmation. For a safer first pass, use the common -WhatIf parameter to preview the proposed operation; use -Confirm when you want PowerShell to ask before proceeding.

Remove-Item -Path C:TempDeleteMe -Recurse -WhatIf
Remove-Item -Path C:TempDeleteMe -Recurse -Confirm

Review the exact path before a recursive deletion. A mistyped or overly broad path can affect more files than intended.

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

Quick cmdlet comparison

Task Cmdlet Useful controls Effect
Inspect items Get-ChildItem -Recurse, -Depth, -Force, -Filter, -File, -Directory Lists matching files and folders
Create New-Item -ItemType File or Directory Creates an item of the selected type
Read Get-Content -Raw, -Tail, -TotalCount, -Encoding, -AsByteStream Reads lines, text as one string, selected lines, or bytes
Replace contents Set-Content -Value Replaces existing content
Append contents Add-Content -Value Adds content after existing content
Duplicate Copy-Item -Recurse for directory trees Copies items to a destination
Relocate or rename Move-Item Set the destination path or filename Moves an item; a changed destination name renames it
Delete Remove-Item -Recurse, -WhatIf, -Confirm Removes an item, optionally with its descendants

Microsoft’s task-oriented examples for working with files and folders are in Working with files and folders – PowerShell. For the distinction between item and content cmdlets, see Basic concepts – PowerShell, Chapter 3.

Quick Recap

SaleBestseller No. 1
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
Seagate 2TB Portable Hard Drive | USB 3.0 (STGX2000400)
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.99
SaleBestseller No. 2
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
Seagate Portable 4TB External Hard Drive HDD – USB 3.0, 1-Year Rescue
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$157.73
Bestseller No. 3
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
Seagate Portable 1TB External Hard Drive HDD – USB 3.0 for PC, Mac, PlayStation, & Xbox, 1-Year Rescue Service (STGX1000400) , Black
This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable; The available storage capacity may vary.
$119.80

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.

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.