Commands / Files

Out-File

Send output to a file

beginner Files

Out-File
 Get-ChildItem | Out-File -FilePath .\listing.txt
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Out-File

Redirects formatted output to a file. Good for logs and quick dumps. For structured data, use Export-Csv or ConvertTo-Json.

-Append adds instead of replacing. > is an alias for Out-File. >> appends.

Try this

Get-Date | Out-File -FilePath .\run.log -Append

Coming from another shell

ShellWhat you might type
bash / zshls > listing.txt
cmd.exedir > listing.txt

More in From bash and From cmd.

Related commands