Как использовать эхо в power shell

How to use Echo in Powershell
powershell out-file

As a PowerShell beginner, one of the most important cmdlets you need to know is Out-File. This incredibly useful cmdlet allows you to export output from PowerShell commands and scripts into text files. Whether you need to log results, generate reports, log events, or save data for later use, PowerShell has several commands that can help you output to a file.

In this comprehensive guide, you’ll learn everything you need to start effectively using the Out-File as a PowerShell beginner. We’ll cover the basics of the cmdlet, including the different commands, syntax, formatting your output, appending vs. overwriting files, and real-world examples.

Quick Links

Key Takeaways

  • To save a PowerShell command’s output to a TXT file, type the command, press Spacebar, type the > (greater than) symbol, press Spacebar, and type the full path to the TXT file.
  • To generate a CSV file from a PowerShell command, type your command, press Spacebar, type the | (pipe) sign, press Spacebar, type “Export-CSV”, press Spacebar, enter the full path to the CSV file, press Spacebar, type “-NoTypeInformation”, and press Enter.

Do you want to save your PowerShell command’s result in a TXT (text) or CSV (comma-separated values) file on your computer? If so, it’s easy to do, and we’ll show you how on your Windows 11 or Windows 10 PC.

Tomas M

However, GUI application has one more thing that may not be desirable when launched using a console: GUI. There is a way to hide that window, but it forces using Start-Process command (or at least this is the only way I am aware of) which separates the script from the process output:

# not a GUI app, but does the trick
$proc = Start-Process -FilePath "podman" `
-ArgumentList stats `
-NoNewWindow -PassThru
$proc.StandardOutput -eq $null # stream is null!

Start-Process offers a way to redirect output to a file using -RedirectStandardOutput parameter, while this works we lose the opportunity to filter and react to output as it is being produced. But, as it often is, this can be solved with another level of indirection:

This wrapper function forwards output to a temporary file which will be removed once the process exists or the script is aborted. While in progress, file content will be checked and forwarded once a second.

I agree, this is not an everyday script and probably for the better. So far it has been applied in two cases: running installer and reading error output (Console.Error.WriteLine) of Terminal.Gui application.

When you store a value in a variable in PowerShell, you can easily access and display that value using different methods. One common approach is to use the Write-Output cmdlet. This cmdlet allows you to display the value of a variable on the console or redirect it to a file or another command.

powershell
Write-Output -InputObject $VariableName
powershell
$UserName = "John Doe"
Write-Output -InputObject $UserName

When you run this code, it will output the value “John Doe” to the console.

Alternatively, you can directly type the name of the variable to output its value. PowerShell will automatically display the value of the variable. For example:

powershell
$UserName = "John Doe"
$UserName

Running this code will also output “John Doe” to the console.

It’s important to note that the Write-Output cmdlet is not always necessary to display the value of a variable. PowerShell automatically outputs the value of a variable if you simply type its name. However, using Write-Output can be useful when you want to explicitly indicate that you are outputting a value or when you need to redirect the output to another command or file.

To output the value stored in a variable in PowerShell, you can use the Write-Output cmdlet or simply type the name of the variable. Both methods allow you to display the value on the console or redirect it to other commands or files.

Other recent questions and answers regarding EITC/IS/WSA Windows Server Administration:

More questions and answers:

  • Field: Cybersecurity
  • Programme: EITC/IS/WSA Windows Server Administration (go to the certification programme)
  • Lesson: Working with PowerShell (go to related lesson)
  • Topic: Storing user input into variables with PowerShell (go to related topic)
  • Examination review

Starting in Windows PowerShell 5.0, Write-Host writes InformationRecord objects to the information stream. This will show if you redirect the information stream to the success stream using 6>&1:

$InformationRecord = Write-Host abc -ForegroundColor Red 6>&1
$InformationRecord | Get-Member TypeName: System.Management.Automation.InformationRecord
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
Computer Property string Computer {get;set;}
ManagedThreadId Property uint ManagedThreadId {get;set;}
MessageData Property System.Object MessageData {get;}
NativeThreadId Property uint NativeThreadId {get;set;}
ProcessId Property uint ProcessId {get;set;}
Source Property string Source {get;set;}
Tags Property System.Collections.Generic.List[string] Tags {get;}
TimeGenerated Property datetime TimeGenerated {get;set;}
User Property string User {get;set;}

This object holds the color information in the MessageData property and doesn’t include any ANSI control codes by itself:

$InformationRecord.MessageData | Get-Member TypeName: System.Management.Automation.HostInformationMessage
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
BackgroundColor Property System.Nullable[System.ConsoleColor] BackgroundColor {get;set;}
ForegroundColor Property System.Nullable[System.ConsoleColor] ForegroundColor {get;set;}
Message Property string Message {get;set;}
NoNewLine Property System.Nullable[bool] NoNewLine {get;set;}

In other words, I don’t think that there is any way to preserve the ANSI control code fromWrite-Host. See also: Is there a way to preserve ANSI control codes in PowerShell command output?

You might consider to write your own Write-Ansi proxy command based on Write-Host but there is a general disadvantage with using the Write-Host command as you can only use a single color for the whole output which requires to make use of the -NoNewLne switch and take that in consideration for any proxy command.

Alternatives

Instead of a using a limited (not redirectable) command like:

Write-Host 'This whole line is red.' -ForegroundColor Red

You might consider using the $PSStyle object:

 "This is $($PSStyle.Foreground.Red)red$($PSStyle.Reset) text" # > .\out.txt

Or, using MarkDown:

'Make this *blue* text' > .\out.txt
(Get-Content .\out.txt | ConvertFrom-MarkDown -AsVT100EncodedString).VT100EncodedString

enter image description here

Set-MarkdownOption -ItalicsForegroundColor '[91m'
('Make this *red* text' | ConvertFrom-MarkDown -AsVT100EncodedString).VT100EncodedString > .\out.txt
Get-Content .\out.txt

enter image description here

Real-World Examples

PowerShell has several advanced techniques for working with output to file, such as using variables and formatting. Here’s an example of how to use a variable with Out-File:

$processes = Get-Process
$processes | Out-File C:\Path\To\File.txt

This command saves the output of Get-Process to a variable, then outputs the variable to a file using Out-File. Formatting output is another advanced technique for working with PowerShell output to the file. Here’s an example of how to format output using Format-Table:

Get-Process | Format-Table -AutoSize | Out-File -FilePath "C:\Logs\Process.txt"

This command formats the output of Get-Process as a table, and then saves it to a file using Out-File.

:/>  Почему вылетают игры на Windows 10 - решаем проблему

The Out-File provides a wide range of functionalities for file management in PowerShell. Here are a few additional examples to demonstrate its versatility:

Example 1: Creating a file with specific encoding

$Services = Get-Service
$Services | Out-File -FilePath "C:\Data\output.txt" -Encoding UTF8

This command will create a new file named “output.txt” with UTF-8 encoding and save the output of the $myData variable to it.

Example 2: Redirecting error output to a file

In PowerShell, you can redirect error output or text to a file using redirection operators. Here’s how you can do it:

Get-ChildItem -Path C:\anothernonexistentfolder 2>> "C:\Logs\ErrorLog.txt"

This command will retrieve the list of processes, suppress any error messages, and redirect the error output to the “output.txt” file.

Try { Get-Process -Name NotExists -ErrorAction Stop
}
Catch { $_.Exception | Out-File -FilePath "C:\Logs\ErrorLog.txt" -Append
}

Redirecting output to a file in PowerShell

In addition to redirecting the output of a command to a file using Out-File, you can also directly write output to a file using the redirection operator (>). This can be useful when you want to quickly save the output of a command without explicitly using the Out-File cmdlet.

Get-Process > "C:\output.txt"

In this example, the output of the Get-Process command will be directly written to the “output.txt” file using the > operator. Similarly, to append to an existing file, file rather than overwriting, use the >> operator:

Get-Process >> "C:\output.txt"

Redirecting Only Errors:

Use the 2> operator to redirect errors. For example, if you want to redirect errors from a command to a file named “errors.txt”:

If you want to append the errors to a file instead of overwriting it, use the 2>> operator:

Get-ChildItem -Path C:\nonexistentfolder 2>> errors.txt

Redirecting All Output:
If you want to redirect all output (standard and error) to the same file, use *>:

Get-ChildItem -Path C:\nonexistentfolder *> alloutput.txt

Here is the list of other useful redirection Operators:

  • 1> or >: Redirects standard output
  • 2>: Redirects error output
  • 3>: Redirects warning output
  • 4>: Redirects verbose output
  • 5>: Redirects debug output
  • 6>: Redirects information output
Get-Process | Select-Object -Property Name, CPU, Memory | Out-File -FilePath "C:\Logs\output.txt"

In this example, we use the Select-Object cmdlet to only retrieve specific properties from the output of the Get-Process command. Then, we use the Out-File cmdlet to save the modified output to the “output.txt” file.

What is the Out-File Cmdlet?

The Out-File cmdlet sends output from a PowerShell command to a text file. The output is written to the specified path and file name. This can be useful for many purposes, such as generating reports, creating backups, or logging events. By default, Out-File creates a new file or overwrites an existing file with the output. It provides several parameters to customize the behavior and format of the output file. There are several commands in PowerShell that can be used to output a file, including Out-File, Add-Content, and Set-Content. 

Out-File is the most basic command for outputting to a file. It saves the output of a command to a file, overwriting any existing content. Add-Content, on the other hand, appends the output to the end of an existing file. Set-Content is similar to Out-File, but it overwrites the entire file instead of just appending to it.

Understanding the Different cmdlets in PowerShell to Write to File

Before diving into the specific commands, let’s look at the differences between Out-File, Add-Content, and Set-Content.

  • Out-File: This command saves the output of a command to a file. It overwrites any existing content in the file. The default file format is Unicode, but you can specify a different format using the encoding parameter.
  • Add-Content: This command appends the output of a command to the end of an existing file. If the file does not exist, it will be created. The default file format is Unicode, but you can specify a different format using the encoding parameter.
  • Set-Content: This command overwrites the entire content of a file with the output of a command. If the file does not exist, it will be created. The default file format is Unicode, but you can specify a different format using the encoding parameter.

Using PowerShell Out-File Cmdlet – Syntax and Examples

Out-File is the most basic command for outputting to a file. It saves the output of a command to a file, overwriting any existing content. Here’s the basic syntax:

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

Here is the list of important parameters for the Out-File cmdlet in PowerShell:

ParameterDescription
-AppendIf specified, the cmdlet will append the output to the end of the existing file instead of overwriting it.
-EncodingSpecifies the character encoding. Values include ascii, utf8, utf7, utf32, unicode, bigendianunicode, and default. utf8NoBOM might be available in newer PowerShell versions.
-ForceAllows the cmdlet to override restrictions that prevent the command from succeeding, apart from security settings. For example, Out-File will overwrite a file even if it has the Read-Only attribute.
-InputObjectSpecifies the input to be written to the file. It accepts an object.
-NoClobberIndicates that the cmdlet should not overwrite (replace) an existing file. If used alongside -Append, this parameter will be ignored.
-NoNewlineOmits the new line character at the end of the output. This is useful if you don’t want to introduce an additional blank line.
-FilePathThe FilePath parameter specifies the path to the output file. It can be either a relative or an absolute path. You can also use the -LiteralPath, which takes the value precisely as entered, without interpreting any characters as wildcards.
-WidthSpecifies the number of characters in each line of output. This parameter is useful when the output width should not exceed a specified number of characters. The default value of the Windows PowerShell console host is 80 characters.

Using the Out-File cmdlet: Basic Example

command | Out-File -FilePath "C:\Path\To\File.txt"

The -FilePath parameter specifies the path and name of the file to save the output to. Here’s an example:

Get-Process | Out-File -FilePath C:\Logs\Processes.txt

This command will save the list of processes to a file called Processes.txt in the specified path.

:/>  Не является приложением win32 что делать windows xp
PowerShell Out-File

The key things to know about the Out-File:

  • It writes command output to a text file
  • You specify the file path and name with the -FilePath parameter
  • It creates the file if it doesn’t exist or overwrites the file if it does exist

Creating CSV files with Out-File PowerShell Cmdlet

Out-File is not only limited to creating text files, but it also supports the creation of CSV files. CSV (Comma-Separated Values) files are widely used for storing and exchanging tabular data. To create a CSV file using Out-File, you need to specify the file extension as “.csv” in the file path. Additionally, you can use the -Encoding parameter to specify the encoding of the CSV file. For example:

Get-Process | Select-Object -Property ProcessName, Id, CPU | ConvertTo-Csv -NoTypeInformation | Out-File -FilePath "C:\Logs\processes.csv" -Encoding utf8

In this example, we convert the $myData variable to CSV format using the ConvertTo-Csv cmdlet, and then redirect the output to a file named “data.csv” with UTF-8 encoding.

However, it’s worth noting that while the Out-File can be used this way, PowerShell provides a more direct cmdlet for this purpose called Export-Csv. The Export-Csv is a more straightforward approach to exporting objects to a CSV file in PowerShell. It eliminates the need for ConvertTo-Csv and Out-File. How to Export to CSV using Export-CSV cmdlet in PowerShell?

Managing file encoding with Out-File

Encoding plays a crucial role in file management, especially when dealing with different languages and special characters. Out-File provides the -Encoding parameter that allows you to specify the encoding of the output file.

The default encoding used by Out-File is ASCII, but you can specify other encoding types such as UTF-8, UTF-16, or Unicode. For example:

Get-Process | Out-File -FilePath "C:\output.txt" -Encoding UTF8

This command will save the output of the Get-Process command to a file named “output.txt” with UTF-8 encoding.

Using delimiters with Out-File

In addition to specifying delimiters for CSV files, Out-File also allows you to use delimiters for other types of files. This can be useful when you want to separate values in a text file or customize the format of the output. For example, let’s say you have a script that generates a list of numbers, and you want to separate them with a semicolon:

$numbers = 1, 2, 3, 4, 5
$numbers -join ";" | Out-File -FilePath "C:\numbers.txt"

In this example, we use the -join operator to join the elements of the $numbers array with a semicolon delimiter, and then redirect the output to a file named “numbers.txt”.

When working with CSV files, you may encounter situations where you need to remove the header (the first row) from the file. Out-File provides a simple way to achieve this using the -NoClobber parameter.

By specifying the -NoClobber parameter, Out-File will prevent overwriting an existing file. This can be useful when you want to remove the header from a CSV file without modifying the rest of the content.

$CSVData = Get-Content -Path "C:\data\Services.csv" | Select-Object -Skip 1
$CSVData | Out-File -FilePath "C:\data\ServicesV2.csv" -NoClobber

In this example, we use the Get-Content cmdlet to read the content of the “data.csv” file and skip the first row using the Select-Object cmdlet. Then, we redirect the modified content back to the same file without overwriting it, effectively removing the header.

Separating columns in a CSV file using Out-File

When working with CSV files, it’s common to separate the columns with a character other than a comma. For example, let’s say you have a CSV file with tab-separated values instead of commas. You can use Out-File to create a new CSV file with tabs as the delimiter:

Get-Service | ConvertTo-Csv -NoTypeInformation -Delimiter "`t" | Out-File -FilePath "C:\data\Services.csv"

In this command, we use the “ConvertTo-Csv” cmdlet to convert the data to CSV format and specify the tab character as the delimiter using the “`t” escape sequence.

Troubleshooting Common Issues with PowerShell Output to File

While PowerShell output to a file is a powerful tool, it can sometimes encounter issues. Here are some common issues and their solutions:

  • File access denied: Ensure that you have the necessary permissions to access the file and that it is not currently open in another program.
  • File not found: Double-check the path and name of the file to ensure that it exists and that there are no typos.
  • Encoding issues: Ensure you are using the correct encoding for your file. Unicode is the default, but you may need to specify a different encoding depending on your needs.

View Your Text or CSV File’s Contents in PowerShell

You can view your newly created text or CSV file’s contents right inside PowerShell. You don’t have to leave the tool and use another app to open your files.

Type PATH
Type C:\Users\mahes\Desktop\SystemInfo.txt
A TXT file's contents displayed in PowerShell using the 'Type' command.

Instantly, PowerShell will load your file’s contents in your open window, allowing you to read the file content.


And that’s all there is to know about saving your PowerShell command results in text or CSV files. Enjoy!

Write-Output and Echo in PowerShell

echo ["message"]
echo "This is a sentence." 
CMD output of echo

The output prints the This is a sentence message. 

  • Text printing.
  • Object printing.
  • Formatting the output using the -Format cmdlets.
  • Specifying the output encoding.
  • Redirecting the output to a file.
  • Parameters that allow users to customize the output.

Example of echo in PowerShell

echo "This is another sentence."
Echo PowerShell output
$name = "Sara"
Set variable $name
echo $name
Run echo on the variable

The output prints the content of the variable.

Available cmdlets are:

  • Format-Custom. Customizes the output with different views.
  • Format-Hex. Shows data in hexadecimal format.
  • Format-List. Creates lists of objects’ properties.
  • Format-Wide. Depicts a single object’s property spanning across the screen.
  • Format-Table. Presents the data in the form of a table.
echo "Number", "Name", "Age", "Location" | Format-Table
echo format table PowerShell output
Function CheckIfNumberIsPrime($num) {
if ($num -lt 2) { echo "$num is not a prime number" } else { $isPrime = $true for ($i = 2; $i -lt $num; $i++) { if ($num % $i -eq 0) { $isPrime = $false break } } if ($isPrime) { echo "$num is a prime number" } else { echo "$num is not a prime number" } }
}

To test the function, run:

CheckIfNumberIsPrime($num)

Replace ($num) with a prime number, for example:

CheckIfNumberIsPrime(7)
Test echo function prime numbers

The output confirms seven is a prime number. Next, try 135:

CheckIfNumberIsPrime(135)
Test echo function in a PowerShell and it's not a prime number

The output verifies 135 is not a prime number.

:/>  InsydeH20 Setup Utility rev 5.0

Example of Write-Output in PowerShell

The Write-Output cmdlet is a powerful command which prints text, objects, and formatted output to the console.

The basic Write-Output syntax is:

Write-Output [object]
Write-Output "This is another sentence."
Write-Output PowerShell
Function PrimeNumber?($num) { if ($num -lt 2) { Write-Output "$num is not a prime number" } else { $isPrime = $true for ($i = 2; $i -lt $num; $i++) { if ($num % $i -eq 0) { $isPrime = $false break } } if ($isPrime) { Write-Output "$num is a prime number" } else { Write-Output "$num is not a prime number" } }
Write-Output function in PowerShell

Test the function with the number seven by running:

PrimeNumber?(7)
Test Write-Output prime number function

Next, test with 135:

PrimeNumber?(135)
Test Write-Output prime number function with no prime number confirmed

The outputs confirm seven is a prime number while 135 is not.

Creating a Text file if it doesn’t exist with Out-File

Sometimes, you may need to create a file only if it doesn’t already exist. Out-File provides a convenient way to achieve this using the -Force parameter.

By specifying the -Force parameter, Out-File will create a new file if it doesn’t exist. If the file already exists, the command will overwrite the existing file. This can be useful when you want to ensure the file exists before redirecting the output to it.

Get-Process | Out-File -FilePath "C:\output.txt" -Force

In this example, the “output.txt” file will be created if it doesn’t already exist, and the output of the Get-Process command will be redirected to it.

Overwriting Read Only Files with Force Parameter in Out-File

By default, Out-File overwrites the content of an existing file. However, there may be situations where you want to explicitly overwrite files that are marked as Read-only. The Out-File command provides the -Force parameter to achieve this.

"New content for the file" | Out-File -FilePath "C:\output.txt" -Force

In this example, the “output.txt” file will be overwritten with the output of the $myData variable, even if it already exists. Alternatively, you can clear the read-only property of the file and then update the file. Here is how:

#Clear the Read Only Property
Set-ItemProperty -Path "C:\Data\readonly.txt" -Name IsReadOnly -Value $false
#Update the file
"New content for the file" | Out-File -Path "readonly.txt"

Write-Host vs. Echo

Write-Output, on the other hand, writes data to the PowerShell pipeline. The output is displayed on the screen if there is no subsequent command in the pipeline to receive this data.

A key Write-Host advantage is the customization capability. Write-Host supports a broader range of formatting options.

To specify the output’s foreground and background colors, use:

Write-Host "Text" -ForegroundColor [Color] -BackgroundColor [Color]

For instance, print a line This sentence is white with a magenta background:

Write-Host "This sentence is white with a magenta background" -ForegroundColor White -BackgroundColor Magenta
Write-Host color chnage

The output is displayed in the requested format.

Next, learn how to set environment variables in Windows.

Conclusion and Next Steps

In this comprehensive guide, we explored everything you need to know about PowerShell Out-file for effective file management. We learned how to redirect output to a file, append data, create CSV files, manage file encoding, create files if they don’t exist, separate columns in CSV files, and use delimiters. We also learned how to remove headers, overwrite files, write output directly to a file, and pipe output to a file. You’ll be well-equipped to handle any output-to-file needs in your PowerShell scripts by mastering these techniques.

With this knowledge, you can now master PowerShell Out-File and enhance your file management capabilities.

What is out-file in PowerShell?

Out-File is a cmdlet in PowerShell that is used to send output to a file. It allows you to redirect the output of a command or script to a text file. You can specify the file path and name, and choose whether to overwrite the existing file or append the output to it.

What is the alternative to out-file in PowerShell?

Set-Content: This cmdlet can be used to write content to a file, similar to out-file. It allows you to specify the file path and the content to be written.

What is the difference between add-content and out-file?

The Add-Content cmdlet is used to append content to an existing file. By default, It adds the new content to the end of the file without overwriting any existing content. This is useful when you want to continuously add new data to a file without losing the previous data.

How do I read a file as text in PowerShell?

To read a file as text in PowerShell, you can use the Get-Content cmdlet. Here’s an example of how to do it:
$content = Get-Content -Path "C:\path\to\file.txt"

How do I pipe output to a file in PowerShell?

How do I write output to a log file in PowerShell?

How do I redirect a PowerShell output to a CSV file?

How can I redirect PowerShell output to a file?

Can I append PowerShell output to an existing file?

Combining PowerShell Output to File and Console

The Tee-Object command allows you to output the result of a command to both a file and the console. Think of it as a “T-junction” for data; it takes input from one source and directs it to two destinations. Here’s the basic syntax:

command | Tee-Object -FilePath "C:\Logs\Commands.txt"

This command will save the output of the command to a file called File.txt in the specified path, as well as display it in the PowerShell console. E.g.,

Get-command -Module PnP.PowerShell | Tee-Object -FilePath "C:\Logs\Commands.txt"

When you use Tee-Object, you can send data down the pipeline to another command AND save it to a file or variable simultaneously. You can also append to a file with -Append. Microsoft’s reference on Tee-Object cmdlet

Appending to an Existing File with PowerShell Out-File cmdlet

In addition to creating new files or overwriting existing ones, the Out-File allows you to append data to a file. This can be useful when you want to continuously update a log file or add new information to an existing file without losing the previous content.

Here’s an example of how to append to a file using Out-File:

# PowerShell Out-File -Append example
Get-ChildItem C:\Users | Out-File -FilePath "C:\Logs\FilesList.txt" -Append

The -Append parameter tells Out-File to append the output to the end of the file, instead of overwriting it. This command will append the list of file folder names in the given path to the end of the file, creating it if it does not exist.

Send a PowerShell Command’s Output to a Text File

To write your PowerShell command’s output to a text (TXT) file, first launch a PowerShell window. Here, type whatever command you need, the output of which you want in a text file. After you’ve typed the command, press Spacebar, type the > (greater than) symbol, press Spacebar, enter the full path to the text file where you want to save the output, and press Enter.

systeminfo > C:\Users\mahes\Desktop\SystemInfo.txt
Как использовать эхо в power shell

As soon as you press Enter, PowerShell creates your specified file and adds your command’s result to it. When that’s done, access your specified path, and you’ll find your newly created file there.

Send a PowerShell Command’s Output to a CSV File

If you want to create a CSV file containing the output of your specified PowerShell command, use the tool’s “Export-CSV” cmdlet.

Get-ChildItem | Export-CSV C:\Users\mahes\Desktop\List.csv -NoTypeInformation
Как использовать эхо в power shell

When you’ve finished running the command, you’ll have a file called “List.csv” on your desktop containing the list of the items in your current directory.