PowerShell’s FileSystem provider lets you inspect, create, read, write, copy, move, and delete files and folders with cmdlets. For common tasks, use Get-ChildItem to list items, New-Item to create them, Get-Content and the content-writing cmdlets to work with data, and Copy-Item, Move-Item, or Remove-Item to manage paths. The examples below use Windows paths; PowerShell’s item cmdlets are provider-based, so related commands can also operate on items exposed by other providers.
How PowerShell file cmdlets fit together
PowerShell separates work with an item’s path and identity from work with its contents. Item cmdlets manage files and directories; content cmdlets read or write data inside files. The FileSystem provider exposes the local file system, while PowerShell’s provider-based command families can also work with items from other providers.
| Task | Cmdlet | Typical use |
|---|---|---|
| Inspect items | Get-ChildItem |
List files and directories, optionally recursively or with filters. |
| Check a path | Test-Path |
Check whether a path exists before acting on it. |
| Create an item | New-Item |
Create a file or directory by specifying -ItemType. |
| Read contents | Get-Content |
Read text lines, a whole file as one string, or bytes. |
| Replace or append contents | Set-Content or Add-Content |
Replace file contents or add content at the end. |
| Duplicate or relocate | Copy-Item or Move-Item |
Copy items and trees, or move an item to another path. |
| Delete items | Remove-Item |
Delete an item; add -Recurse for a directory tree. |
How do you list files and folders?
Use Get-ChildItem to list the direct children of a path. Add -Recurse to include descendants, and -Force to include hidden or system items that are otherwise omitted by default in the FileSystem provider.
Get-ChildItem -Path C:Data
Get-ChildItem -Path C:Data -Recurse
Get-ChildItem -Path C:Data -Force
Use -Depth when you want recursion limited to a number of directory levels rather than the full tree. To filter by a property such as file size, retrieve files and pipe them to Where-Object:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
#1 Best Overall
- 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 C:Data -Recurse -File | Where-Object Length -gt 1MB
PowerShell also provides location cmdlets: Get-Location shows the current location, and Set-Location changes it. Use Test-Path to check whether a path exists before a later copy, write, or delete operation.
How do you create a file or directory?
Specify the item type with New-Item. These commands create a directory and an empty file, respectively:
Rank #2
- 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.
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 using it for an existing folder returns that folder rather than replacing it, while using it for an existing file overwrites the file. Check the target before using -Force on a file.
How do you read a text file?
Get-Content returns a file’s lines by default. Choose a parameter to read the file in a different way or limit the amount returned:
Windows 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 reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #3
- 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.
- Read lines:
Get-Content -Path .log.txt - Read the file as one string:
Get-Content -Path .log.txt -Raw - Read only the last 50 lines:
Get-Content -Path .log.txt -Tail 50 - Read only the first specified number of lines: use
-TotalCount. - Specify text encoding: use
-Encodingwhen encoding matters. - Read bytes: use
-AsByteStreamrather than treating the data as text.
How do you replace or append file contents?
Set-Content replaces the existing content; Add-Content appends new content. For example, the first command sets the file’s content to Complete, while the second adds Next step to the end:
Set-Content -Path .status.txt -Value 'Complete'
Add-Content -Path .status.txt -Value 'Next step'
Choose the cmdlet based on whether existing content should remain. If the file’s text encoding matters, specify -Encoding.
Rank #4
- 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.
How do you copy or move files and folders?
Copy a file or directory tree
Give Copy-Item a source path and destination. Copying a directory tree requires -Recurse:
Copy-Item -Path C:Datareport.csv -Destination C:Backupreport.csv
Copy-Item C:DataProject -Destination C:BackupProject -Recurse
Move or rename an item
Move-Item relocates an item. A destination path with a different name moves and renames it in the same operation:
Free tools Windows power users keep installed
One-click scans. No signup required.
Best Value
- 【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.
Move-Item -Path C:Dataold.txt -Destination C:Dataarchive.txt
An existing destination can cause an operation to fail or require -Force. For a bulk operation, first test the command on a small sample and confirm the destination before applying it broadly.
How do you delete a file or a directory tree?
Delete a single item with Remove-Item. To remove a nonempty directory and its descendants, add -Recurse:
Remove-Item -Path .old.log
Remove-Item -Path C:TempDeleteMe -Recurse
Without -Recurse, removing a directory that contains children can prompt for confirmation. Deleting a tree is consequential, so verify the target path first. Use the common -WhatIf parameter to preview what an operation would do, or -Confirm when you want a confirmation prompt.
What should you check before a bulk file operation?
- Confirm the current location with
Get-Locationif you use relative paths. - Check that the intended source and destination paths are correct; use
Test-Pathwhere existence matters. - Review the result of
Get-ChildItembefore applying a recursive copy or deletion. - Use
-WhatIffor a preview when appropriate, and test copy or move behavior on a small sample before running it over many items. - Use
-Forcedeliberately: it can include hidden items in listings and can overwrite an existing file in relevant operations.
For Microsoft’s procedural examples and parameter details, see Working with files and folders – PowerShell, the about_Core_Commands overview, and the references for Get-ChildItem, Get-Content, Set-Content, Copy-Item, Move-Item, and the FileSystem provider.
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.




