PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated 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 matchSome links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
In PowerShell 7, use Set-Content to create or replace a text file, then Add-Content to add more text without removing what is already there:
$path = '.notes.txt'
'First line' | Set-Content -LiteralPath $path -Encoding utf8NoBOM
'Second line' | Add-Content -LiteralPath $path -Encoding utf8NoBOM
The file will contain both lines. These examples target PowerShell 7.x; Windows PowerShell 5.1 has different encoding defaults and does not support the utf8NoBOM encoding name.
Create a text file
Set-Content is usually the clearest choice when your goal is to write text. It creates the file if needed and replaces the contents if the file already exists:
'Hello from PowerShell' | Set-Content -Path '.example.txt' -Encoding utf8NoBOM
Here, -Path identifies the destination and the string before the pipe is the content to write. A path beginning with . 5c is relative to the current directory. Check that directory with Get-Location; use an absolute path if you want to specify the destination unambiguously.
#1 Best Overall
- Sturdy Construction: Our Lined Spiral Journal Notebook is built to last with a sturdy metal twin-wire binding and a tough hardcover. The water-resistant cover shields your notes from damage, while the double-wire design allows for easy folding and flat laying.
- High-Quality Paper: Crafted from 100 GSM thick, ink-friendly paper, our notebook prevents ink bleed-through and ghosting. It accommodates various pens, including ballpoint, gel, and fountain pens. Each page features a day header for effortless date tracking.
- Organized and Functional Design: With 140 lined pages and a 6-page blank table of contents, our notebook offers ample space for note-taking and easy referencing. An inner pocket keeps miscellaneous items secure, and an elastic closure band ensures the notebook stays closed when not in use.
- Versatile Usage: Suitable for office, school, and home environments, our notebook is perfect for journaling, note-taking, drawing, goal setting, Bible, and planning. It's a thoughtful present for friends, family, classmates, and colleagues.
- Medium-Sized Portability: Measuring 5.7 inches x 7.9 inches, our medium notebook strikes the perfect balance between portability and functionality. Its sturdy construction and aesthetic design make it an ideal companion for all your writing endeavors.
For an empty file, use New-Item:
New-Item -Path '.empty.txt' -ItemType File
To create a file and give it initial content in the same command:
New-Item -Path '.' -Name 'example.txt' -ItemType File -Value 'Initial content'
New-Item creates a file item; Set-Content is generally more direct when writing or replacing text is the main task. See Microsoft Learn for Set-Content and New-Item.
Append text without replacing the file
Use Add-Content to add text at the end of a file. Unlike Set-Content, it preserves the content already there. It can also create the file if it does not exist:
Recommended Free Tools
Add-Content -LiteralPath '.example.txt' -Value 'A new line' -Encoding utf8NoBOM
You can pipe a string instead:
'Another line' | Add-Content -LiteralPath '.example.txt' -Encoding utf8NoBOM
To append several lines, pass an array of strings. Each array entry is written as a separate line in this example:
@(
'First appended line'
'Second appended line'
'Third appended line'
) | Add-Content -LiteralPath '.example.txt' -Encoding utf8NoBOM
If you deliberately need to join text directly with no trailing newline, use -NoNewline on both commands:
Rank #2
- BEST-SELLING HARDCOVER JOURNAL: This classic 5.6" x 8" vegan leather journal features a durable and water-resistant cover, 160 college ruled lined pages, inner expandable pocket, sticker labels, ribbon bookmark & elastic closure band.
- PREMIUM PAPER: Made with high-quality, 100 gsm acid-free paper in light ivory color, our journal paper is thicker than average notebooks & note pads, so you can confidently use most pens, pencils, and markers without ghosting and bleed-through.
- LAY FLAT DESIGN FOR WRITING EASE: Our thread-bound, college ruled notebook is designed to lay flat, making it easier to write for both right and left-handed users. It’s the perfect notebook for journaling, note taking and planning.
- INNER POCKET: Includes an expandable inner storage pocket to store appointment cards, notes, receipts, and more. Personalize your journal cover & spine with the sheet of sticker labels included.
- VERSATILE LINED NOTEBOOK: Ideal for journaling, note-taking, planning, or creative writing. Whether you're making a to-do list, capturing ideas, or writing notes, this journal makes a perfect notebook for school, work, or home office.
Set-Content -LiteralPath '.joined.txt' -Value 'Part 1' -NoNewline -Encoding utf8NoBOM
Add-Content -LiteralPath '.joined.txt' -Value 'Part 2' -NoNewline -Encoding utf8NoBOM
The result is Part 1Part 2. For ordinary notes and logs, line breaks are usually easier to read. Refer to Microsoft Learn for Add-Content.
A complete example, including a missing directory
Writing a file does not create missing parent directories. Create the directory first, then write and append:
Free tools Windows power users keep installed
One-click scans. No signup required.
$directory = Join-Path $PWD 'logs'
$path = Join-Path $directory 'app.log'
New-Item -Path $directory -ItemType Directory -Force | Out-Null
'Application started' | Set-Content -LiteralPath $path -Encoding utf8NoBOM
"Application finished: $(Get-Date -Format 's')" |
Add-Content -LiteralPath $path -Encoding utf8NoBOM
Get-Content -LiteralPath $path
-Force makes this directory-creation pattern convenient when the directory already exists. It does not bypass security permissions. If a relative path fails, check the current directory with Get-Location and confirm the parent exists with Test-Path -LiteralPath $directory.
Which command should you use?
| Command | What it does to an existing file | Good fit |
|---|---|---|
New-Item -ItemType File |
Creates a file item; an existing file is not a way to replace its contents | An empty file or a new file with initial -Value |
Set-Content |
Replaces its contents | Writing or replacing text |
Add-Content |
Preserves contents and appends text | Adding lines to notes or logs |
Out-File |
Replaces by default; -Append appends |
Saving formatted PowerShell output for a person to read |
> |
Overwrites without warning | Short redirection when the overwrite is intentional |
>> |
Appends | Short redirection when its formatting and encoding behavior are suitable |
Set-Content and Add-Content are explicit choices for text. Out-File writes PowerShell’s formatted display representation of objects, not the original objects in a reusable structured form. For human-readable command output, for example:
Get-Process | Out-File -FilePath '.processes.txt' -Encoding utf8NoBOM
Get-Process | Out-File -FilePath '.processes.txt' -Append -Encoding utf8NoBOM
Formatted tables may be limited by the host’s output width. When saving wide formatted output, Out-File -Width can increase the width used for the file. For machine-readable data, use a format-specific export method rather than relying on terminal formatting. See Microsoft Learn’s Out-File documentation.
Rank #3
- 320 Pages Paper - Journaling notebooks with 320 pages provides you with enough writing space. A5 notebook journal with 100gsm paper, thicker than normal paper, will not cause bleeding, ghosting or smudging and is suitable for most types of pens.
- Waterproof Hard Cover - Leather journal have a comfortable touch. Durable and waterproof hardcover journal notebook protects the inside of the pages better than a soft cover and provides a comfortable writing surface.
- Notebook with Pockets - Journal for women comes with a paper pocket and gold trimmed fabric to make the pockets more durable. Journals for writing have colorful ribbon and elastic band and a pen insert on the right side of the journal.
- College Ruled Journal - Lined journal is a college ruled notebook on 100 GSM paper, and the writing journal is designed to lay flat with colored tabs. There is a DATE bar at the top of each page. Helps you remember those important dates and find the page.
- Cagie Brand Support- You can purchase our products with full confidence! if you don't love the journal notebook due to any quality issues, simply contact us directly within 1 year and we will send you a hassle-free replacement journal for men women or full refund.
Redirection shortcuts: > and >>
These operators are concise, but remember that > overwrites and >> appends:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
'First line' > '.example.txt'
'Second line' >> '.example.txt'
Redirection behaves like sending output to Out-File without specifying its other parameters. Encoding behavior differs between PowerShell editions, so the explicit Set-Content and Add-Content pattern is easier to audit in scripts. Microsoft documents the details in about_Redirection.
Choose an encoding deliberately
Encoding is how text characters are represented as bytes. For modern, cross-platform text in PowerShell 7.x, UTF-8 without a byte-order mark is a sensible general-purpose choice:
$text = 'Café — 東京'
Set-Content -LiteralPath '.unicode.txt' -Value $text -Encoding utf8NoBOM
Add-Content -LiteralPath '.unicode.txt' -Value 'Привет' -Encoding utf8NoBOM
Use the same encoding when you create and append to a file you control. If you append to a file made by another program, determine its encoding first and specify a matching encoding; choosing the wrong one can corrupt non-ASCII characters.
| PowerShell environment or target | Encoding choice | Important detail |
|---|---|---|
| PowerShell 7.x | -Encoding utf8NoBOM |
UTF-8 without a BOM; suitable for many modern text workflows. |
| Windows PowerShell 5.1, modern UTF-8 consumer | -Encoding UTF8 |
Writes UTF-8 with a BOM. Do not use the PowerShell 7 utf8NoBOM example unchanged. |
| Windows PowerShell 5.1, legacy ANSI consumer | -Encoding Default |
Uses the active Windows ANSI code page; use only when the receiving application requires it. |
| Target specifically requires UTF-16 little-endian | -Encoding Unicode |
Writes UTF-16LE, normally with a BOM. |
PowerShell 6 and later generally use UTF-8 without a BOM for text output defaults. Windows PowerShell 5.1 is less consistent: Out-File and redirection use UTF-16LE by default, while Set-Content and Add-Content use the system default ANSI code page when creating a new file. The meaning of utf8 also differs: Windows PowerShell 5.1 writes UTF-8 with a BOM, while PowerShell 6 and later use UTF-8 without one. Avoid UTF-7 for new work. See Microsoft’s about_Character_Encoding.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Rank #4
- Hardcover notebook with line-ruled pages (front and back); ideal for notes, lists, journaling, and more
- 240 pages
- Archival quality; acid free
- Expandable inner pocket for storing loose items
- Includes bookmark and elastic closure
When Add-Content is used without an explicit encoding, its behavior depends on the existing file and PowerShell edition. It can detect an existing encoding in relevant cases; a file without a BOM can require a fallback, which differs between Windows PowerShell 5.1 and PowerShell 6+. Explicitly set the encoding when you know what the file uses. In particular, redirection and Out-File -Append do not attempt to match an existing file’s encoding automatically.
Prevent accidental overwrites
Set-Content intentionally replaces existing content. If overwriting would be unsafe, check before writing:
$path = '.important.txt'
if (Test-Path -LiteralPath $path) {
throw "Refusing to overwrite existing file: $path"
}
'Initial content' | Set-Content -LiteralPath $path -Encoding utf8NoBOM
Alternatively, Out-File supports -NoClobber:
'Initial content' | Out-File -FilePath '.important.txt' -NoClobber -Encoding utf8NoBOM
Set-Content does not have an equivalent -NoClobber parameter. The check-then-write approach is useful for simple scripts, but another process could create the file after the check; use an approach appropriate to your concurrency and safety requirements if multiple processes may write to the same destination.
Use literal paths for unusual filenames
Many file cmdlets interpret wildcard characters such as * and ? in -Path. Use -LiteralPath when the name must be treated exactly as supplied, including brackets:
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 →Add-Content -LiteralPath '.report[final].txt' -Value 'Approved' -Encoding utf8NoBOM
Use -Path when wildcard expansion is intentional, such as targeting a group of files:
Best Value
- 【Vintage Leather Journal Notebook】The perfect rule notebook is perfect for travelers,business people,students for writing journals,journaling, personal daily journals,travel journals,work notebooks or for taking notes in college classes or meetings.The exquisite print symbolizes tenacious vitality,which will always remain alive.No matter what difficulties and obstacles you face,you can face it firmly.
- 【Hardcover Leather journal】This medium 5.7 x 8.3 inchs A5 lined journal notebook features a waterproof brown faux leather cover,Leather feels soft and comfortable,inner ribbon bookmark and elastic closure band,for all your drawing, writing, sketching, note-taking, traveling, etc.At the same time, it is perfect to carry around or put in a bag or purse.
- 【256 Pages Premium Paper】We use 256 Pages (128 Sheets) 80Gsm acid-free paper thick lined paper,Line spacing 8.5mm,so you can confidently use most pens, pencils, and markers without ghosting and bleed-through.The Light yellow paper resists damage from light and air and the paper protects your eyes from irritation.
- 【180° Lay Flat Design】The 180° lay flat design makes writing easier, reading more convenient, and taking notes more efficient.At the same time, the hardcover notebook is designed with elastic closure band to make it tightly closed to protect your content, and the inner paper will not be curled and kept flat.
- 【Ideal Business Notebook Gift】Journal with beautiful print is perfect for mom,dad,girls, boys, children,friends,wife,husband,friends,daughters, sons,granddaughter,teachers, students, artists,writers,designers, journalists,office clerks,business women/men,on Christmas, Halloween, New Year, Nirthday, Children's Day,Mothers Day,Fathers Day,Valentine's Day,Anniversary Gift,etc.
Add-Content -Path '.logs*.txt' -Value 'Reviewed' -Encoding utf8NoBOM
Common problems and recovery
“The path cannot be found”
The parent directory may not exist, the relative path may be resolving from an unexpected current directory, or the path may contain a typo. Inspect the location and parent:
Get-Location
Test-Path -LiteralPath (Split-Path -Parent $path)
Create a missing parent before writing:
New-Item -Path (Split-Path -Parent $path) -ItemType Directory -Force | Out-Null
“Access is denied” or the file is read-only
Check that you have write permission to the destination and that another process is not preventing access. If the obstacle is only a read-only file attribute and you otherwise have permission, Add-Content supports -Force:
Add-Content -LiteralPath '.example.txt' -Value 'Additional text' -Force -Encoding utf8NoBOM
-Force does not bypass NTFS permissions or other access-control rules, unlock a file held by another process, or grant access to a protected directory. If access remains denied, use a permitted location or resolve the actual permission or file-lock issue rather than assuming -Force can override it.
Accented or non-English characters look corrupted
A likely cause is that the file was created, appended, or read using mismatched encodings. For a file you control, use an explicit consistent encoding for writes and, when needed, for Get-Content. For a file created elsewhere, identify its encoding rather than assuming it is UTF-8.
The output looks like a table or is cut off
This is expected when Out-File receives objects: it saves their formatted display representation. Table formatting can also be affected by the host width. Use Set-Content or Add-Content for plain strings; use a format-specific exporter for structured data.
The file contains binary data
These examples are for text. Do not write an image, executable, archive, or other arbitrary binary data as though it were a string; text encoding can change the bytes. Use a binary-aware method appropriate to that data instead.
Verify the result
Read the text back and inspect the file metadata:
Get-Content -LiteralPath $path
Get-Item -LiteralPath $path | Select-Object FullName, Length, LastWriteTime
Test-Path -LiteralPath $path
For a script that must confirm an expected string is present, read the complete file with -Raw and test it:
$content = Get-Content -LiteralPath $path -Raw
if ($content -notmatch 'Second line') {
throw 'Expected text was not found.'
}
Length is the file size in bytes, not a count of characters. Get-Content also accepts -Encoding if you need to specify how the file should be read; see Microsoft Learn: Get-Content.
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.

