| by Arround The Web | No comments

Echo Equivalent for Script Testing in PowerShell

The “Echo” command is used in computing to output a value that has been passed to it, such as variables or strings. This command is available for all operating systems and is usually utilized inside the PowerShell scripts and batch files. The PowerShell has several echo equivalent commands that are used to output a text, string, or variable.

This post will present various Echo equivalent commands used in PowerShell.

What is the Echo Equivalent for Script Testing in PowerShell?

These are the “Echo” equivalents in PowerShell:

    • Write-Output
    • Write-Host

Method 1: Use “Write-Output” Command as an “Echo” Equivalent

The “Echo” cmdlet is an alias of the “Write-Output”. This command is equivalent to the Echo command and is mostly used inside the scripts or console to display the text outputs. Moreover, it is also utilized to send the objects to the “Output Stream” or the “Success Pipeline”.


This is the basic syntax of the “Write-Output” cmdlet:

> Write-Output "text here"


Now, let’s print out a message on the PowerShell console using the Write-Output command:

> Write-Output "This is an output text."


As you can see, the “Write-Output” cmdlet has performed the same functionality as an “Echo” command, which is to output the text.

Method 2: Use “Write-Host” Command as an “Echo” Equivalent

Another equivalent to the “Echo” cmdlet in PowerShell is the “Write-Host” cmdlet. It is used to write the customized output to the host, such as colored text or the colored background of the text.


Here is the basic syntax of the “Write-Host” cmdlet:

> Write-Host "text here"


Let’s take the help of the example to demonstrate the working of the “Write-Host” cmdlet:

> Write-Host "Hello People" -BackgroundColor Red

In the above code example:

    • First, we have added a message using the “Write-Host” cmdlet.
    • After that, specify the “-BackgroundColor” parameter and assign the value “Red”.

It can be observed that the “Write-Host” cmdlet has performed the same functionality as an “Echo” command. Moreover, it also customized the output by changing its background color.


The “Echo” equivalent commands in PowerShell are the “Write-Output” and the “Write-Host”. Both of the commands mimic the functionality, which is to write the text as an output. “Write-Output” sends the objects to the output stream, while the “Write-Host” command wraps the text information inside and output to the information stream and also customizes it. This article has presented two Echo equivalents in PowerShell.

Share Button

Source: linuxhint.com

Leave a Reply