22external help file : Microsoft.PowerShell.Commands.Utility.dll-Help.xml
33Locale : en-US
44Module Name : Microsoft.PowerShell.Utility
5- ms.date : 12/12/2022
5+ ms.date : 07/27/2023
66online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/out-file?view=powershell-7.2&WT.mc_id=ps-gethelp
77schema : 2.0.0
88title : Out-File
@@ -95,15 +95,15 @@ Out-File -FilePath .\Process.txt -InputObject $Procs -Encoding ASCII -Width 50
9595```
9696
9797The ` Get-Process ` cmdlet gets the list of processes running on the local computer. The ** Process**
98- objects are stored in the variable, ` $Procs ` . ` Out-File ` uses the ** FilePath** parameter and creates
99- a file in the current directory named ** Process.txt** . The ** InputObject** parameter passes the
100- process objects in ` $Procs ` to the file ** Process.txt** . The ** Encoding** parameter converts the
101- output to ** ASCII** format. The ** Width** parameter limits each line in the file to 50 characters so
102- some data might be truncated.
98+ objects are stored in the variable, ` $Procs ` . ` Out-File ` uses the ** FilePath** parameter and
99+ creates a file in the current directory named ** Process.txt** . The ** InputObject** parameter passes
100+ the process objects in ` $Procs ` to the file ** Process.txt** . The ** Encoding** parameter converts
101+ the output to ** ASCII** format. The ** Width** parameter limits each line in the file to 50
102+ characters so some data might be truncated.
103103
104104### Example 4: Use a provider and send output to a file
105105
106- This example shows how to use the ` Out-File ` cmdlet when you are not in a ** FileSystem** provider
106+ This example shows how to use the ` Out-File ` cmdlet when you aren't in a ** FileSystem** provider
107107drive. Use the ` Get-PSProvider ` cmdlet to view the providers on your local computer. For more
108108information, see [ about_Providers] ( ../Microsoft.Powershell.Core/About/about_Providers.md ) .
109109
@@ -132,8 +132,8 @@ The `Set-Location` command uses the **Path** parameter to set the current locati
132132provider ` Alias: ` . The ` Get-Location ` cmdlet displays the complete path for ` Alias: ` .
133133` Get-ChildItem ` sends objects down the pipeline to the ` Out-File ` cmdlet. ` Out-File ` uses the
134134** FilePath** parameter to specify the complete path and filename for the output,
135- ** C:\TestDir\AliasNames.txt** . The ` Get-Content ` cmdlet uses the ** Path** parameter and displays the
136- file's content in the PowerShell console.
135+ ** C:\TestDir\AliasNames.txt** . The ` Get-Content ` cmdlet uses the ** Path** parameter and displays
136+ the file's content in the PowerShell console.
137137
138138### Example 5: Set file output width for entire scope
139139
@@ -151,7 +151,9 @@ function DemoDefaultOutFileWidth() {
151151
152152 Get-ChildItem Env:\ > $logFile
153153
154- Get-Service -ErrorAction Ignore | Format-Table -AutoSize | Out-File $logFile -Append
154+ Get-Service -ErrorAction Ignore |
155+ Format-Table -AutoSize |
156+ Out-File $logFile -Append
155157
156158 Get-Process | Format-Table Id,SI,Name,Path,MainWindowTitle >> $logFile
157159 }
@@ -201,8 +203,8 @@ The acceptable values for this parameter are as follows:
201203- `utf8NoBOM` : Encodes in UTF-8 format without Byte Order Mark (BOM)
202204- `utf32` : Encodes in UTF-32 format.
203205
204- Beginning with PowerShell 6.2, the **Encoding** parameter also allows numeric IDs of registered code
205- pages (like `-Encoding 1251`) or string names of registered code pages (like
206+ Beginning with PowerShell 6.2, the **Encoding** parameter also allows numeric IDs of registered
207+ code pages (like `-Encoding 1251`) or string names of registered code pages (like
206208` -Encoding "windows-1251"` ). For more information, see the .NET documentation for
207209[Encoding.CodePage](/dotnet/api/system.text.encoding.codepage?view=netcore-2.2).
208210
@@ -241,8 +243,8 @@ Accept wildcard characters: False
241243
242244# ## -Force
243245
244- Overrides the read-only attribute and overwrites an existing read-only file. The **Force** parameter
245- does not override security restrictions.
246+ Overrides the read-only attribute and overwrites an existing read-only file. The **Force**
247+ parameter doesn't override security restrictions.
246248
247249` ` ` yaml
248250Type: System.Management.Automation.SwitchParameter
@@ -275,10 +277,11 @@ Accept wildcard characters: False
275277
276278# ## -LiteralPath
277279
278- Specifies the path to the output file. The **LiteralPath** parameter is used exactly as it is typed.
279- Wildcard characters are not accepted. If the path includes escape characters, enclose it in single
280+ Specifies the path to the output file. The **LiteralPath** parameter is used exactly as it's typed.
281+ Wildcard characters aren't accepted. If the path includes escape characters, enclose it in single
280282quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape
281- sequences. For more information, see [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).
283+ sequences. For more information, see
284+ [about_Quoting_Rules](../Microsoft.Powershell.Core/About/about_Quoting_Rules.md).
282285
283286` ` ` yaml
284287Type: System.String
@@ -312,7 +315,7 @@ Accept wildcard characters: False
312315
313316# ## -NoNewline
314317
315- Specifies that the content written to the file does not end with a newline character. The string
318+ Specifies that the content written to the file doesn't end with a newline character. The string
316319representations of the input objects are concatenated to form the output. No spaces or newlines are
317320inserted between the output strings. No newline is added after the last output string.
318321
@@ -330,11 +333,11 @@ Accept wildcard characters: False
330333
331334# ## -Width
332335
333- Specifies the number of characters in each line of output. Any additional characters are truncated,
334- not wrapped. If this parameter is not used, the width is determined by the characteristics of the
335- host. The default for the PowerShell console is 80 characters. If you want to control the width for
336- all invocations of `Out-File` as well as the redirection operators (`>` and `>>`), set
337- ` $PSDefaultParameterValues['out-file:width'] = 2000` before using `Out-File`.
336+ Specifies the maximum number of characters in each line of output. Any additional characters are
337+ truncated, not wrapped. If this parameter isn't used, the width is determined by the
338+ characteristics of the host. The default for the PowerShell console is 80 characters. If you want
339+ to control the width for all invocations of `Out-File` as well as the redirection operators (`>`
340+ and `>>`), set `$PSDefaultParameterValues['out-file:width'] = 2000` before using `Out-File`.
338341
339342` ` ` yaml
340343Type: System.Int32
@@ -366,7 +369,7 @@ Accept wildcard characters: False
366369
367370# ## -WhatIf
368371
369- Shows what would happen if the cmdlet runs. The cmdlet is not run.
372+ Shows what would happen if the cmdlet runs. The cmdlet isn't run.
370373
371374` ` ` yaml
372375Type: System.Management.Automation.SwitchParameter
@@ -409,10 +412,10 @@ To send a PowerShell command's output to the `Out-File` cmdlet, use the pipeline
409412can store data in a variable and use the **InputObject** parameter to pass data to the `Out-File`
410413cmdlet.
411414
412- ` Out-File` saves data to a file but it does not produce any output objects to the pipeline.
415+ ` Out-File` saves data to a file but it doesn't produce any output objects to the pipeline.
413416
414417PowerShell 7.2 added the ability to control how ANSI escape sequences are rendered. ANSI-decorated
415- output that is passed to `Out-File` can be altered based on the setting of the
418+ output that's passed to `Out-File` can be changed based on the setting of the
416419` $PSStyle.OutputRendering` property. For more information, see
417420[about_ANSI_Terminals](/powershell/module/microsoft.powershell.core/about/about_ansi_terminals).
418421
0 commit comments