TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

PowerShell Out-File

PowerShell Out-File with What is PowerShell, History of PowerShell, Features of PowerShell, PowerShell vs CMD, PowerShell Scripting, PowerShell Versions, PowerShell Commands, PowerShell Looping, PowerShell Conditions, PowerShell Array, PowerShell Brackets etc.

<< Back to POWERSHELL

PowerShell Out-File

The Out-File cmdlet in PowerShell sends the output to a specific file. When you need to use its parameters, use this cmdlet instead of redirection operator (>).

Syntax

Out-File 
[-FilePath] <string> 
[[-Encoding] {unknown | string | unicode | bigendianunicode | utf8 | utf7 | utf32 | ascii | default | oem}] 
[-Append] 
[-Force] 
[-NoClobber] 
[-Width <int>] 
[-NoNewline] 
[-InputObject <psobject>] 
[-WhatIf] 
[-Confirm]  
[<CommonParameters>]

Out-File 
[[-Encoding] {unknown | string | unicode | bigendianunicode | utf8 | utf7 | utf32 | ascii | default |oem}] 
-LiteralPath <string> 
[-Append] 
[-Force] 
[-NoClobber] 
[-Width <int>] 
[-NoNewline] 
[-InputObject <psobject>]
[-WhatIf] 
[-Confirm]  
[<CommonParameters>]

Parameters

Followings are the parameters used in this cmdlet:

-FilePath and -LiteralPath

Both the parameters are used to specify the path to the file in the command.

-Encoding

This parameter specifies the type of character used in the file. The default value of this parameter is UTF8NoBOM. Followings are the acceptable values for this parameter:

  • ASCII
  • Unicode
  • UTF7
  • BigEndianUnicode
  • UTF8
  • UTF8BOM
  • UTF8NoBOM
  • OEM
  • UTF32

-Append

This parameter is used to add the output at the end of an existing file.

-Force

This parameter overwrites the existing read-only files and the read-only attributes. It does not override security restrictions.

-NoClobber

This parameter prevents the existing files with the same name to be overwritten and shows you a message that the file already exists.

-Width

This parameter specifies the number of characters in each output line.

-NoNewLine

This parameter specifies that the content which is written to the file does not end with a new line character.

-InputObject

This parameter specifies those objects which are written to the file.

-WhatIf

This parameter describes what would happen if the cmdlet executes.

-Confirm

This parameter prompts you a confirmation before executing a cmdlet.

Examples

Example 1:

PowerShell Out-File

The command in this example sends the output of the get-childitem cmdlet to the text file whose path is specified in the command by using the -FilePath parameter.

Example 2:

PowerShell Out-File

The command in this example does not send the output of the get-process cmdlet to the k.txt file, and it shows an error because the file already exists. The file k.txt cannot be overwritten because of the -NoClobber parameter in the command.






Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf