Quick Actions
Set-Content
Description
Writes new content or replaces the content in a file.
Command
Set-Content
Examples
Create a new file with content (overwrites if exists)
Set-Content -Path .\NewFile.txt -Value 'Hello, World!'
Clear the content of a file
Set-Content -Path .\OldFile.txt -Value ''
Parameters
Parameter | Type | Required | Description |
---|---|---|---|
[-Path <String[]>] |
string | No | Specifies the path to an item. |
[-Value <Object[]>] |
string | No | The content to be written to the file. |
Command Info
Category:
File System
Type:
Powershell
Views:
12
Status:
Active
Tags
powershell
write
file
create
sc