Skip to main content This browser is no longer supported. Show
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support. Out-File
In this articleSyntax
DescriptionThe ExamplesExample 1: Send output and create a fileThis example shows how to send a list of the local computer's processes to a file. If the file does not exist,
The Example 2: Prevent an existing file from being overwrittenThis example prevents an existing file from being overwritten. By default,
The Example 3: Send output to a file in ASCII formatThis example shows how to encode output with a specific encoding type.
The Example 4: Use a provider and send output to a fileThis example shows how to use the
The Example 5: Set file output width for entire scopeThis example uses
For more information about Parameters-AppendAdds the output to the end of an existing file.
-ConfirmPrompts you for confirmation before running the cmdlet.
-EncodingSpecifies the type of encoding for the target file. The default value is The acceptable values for this parameter are as follows:
Beginning with PowerShell 6.2, the Encoding parameter also allows numeric IDs of registered code pages (like
Note UTF-7* is no longer recommended to use. As of PowerShell 7.1, a warning is written if you specify
-FilePathSpecifies the path to the output file.
-ForceOverrides the read-only attribute and overwrites an existing read-only file. The Force parameter does not override security restrictions.
-InputObjectSpecifies the objects to be written to the file. Enter a variable that contains the objects or type a command or expression that gets the objects.
-LiteralPathSpecifies the path to the output file. The LiteralPath parameter is used exactly as it is typed. Wildcard characters are not accepted. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences. For more information, see about_Quoting_Rules.
-NoClobberNoClobber prevents an existing file from being overwritten and displays a message that the file already exists. By default, if a file exists in the specified path,
-NoNewlineSpecifies that the content written to the file does not end with a newline character. The string representations of the input objects are concatenated to form the output. No spaces or newlines are inserted between the output strings. No newline is added after the last output string.
-WhatIfShows what would happen if the cmdlet runs. The cmdlet is not run.
-WidthSpecifies the number of characters in each line of output. Any additional characters are truncated, not wrapped. If this parameter is not used, the width is determined by the characteristics of the host. The default for the PowerShell console is 80 characters. If you want to control the width for all invocations of
InputsPSObject You can pipe any object to OutputsNone
NotesInput objects are automatically formatted as they would be in the terminal, but you can
use a To send a PowerShell command's output to the
PowerShell 7.2 added the ability to control how ANSI escape
sequences are rendered. ANSI-decorated output that is passed to
FeedbackSubmit and view feedback for Which of the following will the Split command do on a file?Which of the following will the split command do on a file when no other options are specified? It will split a file into new equally sized files that are 1/10th of the original file size.
Which of the following commands will count the number of lines in a file named?The wc command is used to find the number of lines, characters, words, and bytes of a file. To find the number of lines using wc, we add the -l option. This will give us the total number of lines and the name of the file.
Which of the following commands will count the number of lines?Use wc –lines command to count the number of lines. Use wc –word command to count the number of words.
Which of the following is a type of software that allows a piece of hardware to host multiple operating system?Virtualization software — programs that allow you to run multiple operating systems simultaneously on a single computer — allows you to do just that. Using virtualization software, you can run multiple operating systems on one physical machine.
|