Skip to Content

Set-Content


Description
Writes new content or replaces existing content in a file.
Syntax
Set-Content [-Path] <String[]> [-Value] <Object[]> [-Force] [-PassThru]
Example
Set-Content -Path 'C:\temp\output.txt' -Value 'Hello World'
Parameters
Path: Required. Specifies the path of the item that receives the content
Value: Required. Specifies the new content for the item
Force: Optional. Forces the command to run without user confirmation
PassThru: Optional. Returns content object representing the content
Return type
None or System.String
Aliases
sc
Supported Windows versions
Windows PowerShell 2.0 and laterWindows 7Windows 8Windows 10Windows 11Windows Server 2008 R2 and later