Hi, Damian Garbus here. I’m so excited that you are here. Today I want to show 6 the most basic Powershell commands for output preparing. If you learn Powershell this list will help you use more efficiently commands in your new script. In my opinion, learning PowerShell commands is like learn words in foreign languages. If you know more, you can write faster scripts and automate your job.

Powershell output commands
Write-Host
The basic command to print output in the Powershell console. Remember: This command does not create an Powershell object, so it’s cannot be assigned to the variable. Let’s play with this command…
Write-Host
Write-Host "Poshland"
Write-Host "Poshland" -ForegroundColor Green
$x = Write-Host "Poshland" -ForegroundColor Green
$x
(Write-Host "Poshland" -ForegroundColor Green).GetType()

Read-Host
This command is not used to prepare output data from powershell scripts and functions. However, I joined it to this post because it allows interaction with the console and the Powershell script. It will help you to input some string to your script or Powershell console. You can assign the result of this command to the variable.
Read-Host "Please type your string"
$x = Read-Host "Please type your string"
$x

Write-Output
This command is very similar to Write-Host but has very important deference. The result of this command can be assigned to the variable because it’s an object.
Write-Output
Write-Output -InputObject "Poshland Blog"
$x = Write-Output -InputObject "Poshland Blog"
$x
$x.GetType()

Write-Verbose
Write-Verbose is a specific command very important during writing Powershell scripts and functions. It’s used when you want to print more details in result from the script but only in Verbose mode. See example:
[cmdletbinding()]
Param()
Write-Verbose "My hide output only for verbose mode"
Write-Output "Script output"

Write-Warning
The next one very important command in Powershell. You can use this command in your script or function to show a warning. By default it only prints output and you cannot assign the results of this command to the variable. In the future, I will write about “try{} catch{}” commands which will allow you for more advanced use Write-Warning command.
Write-Warning -Message "My Custom Warning"
$x = Write-Warning -Message "My Custom Warning"

Write-Error
Did you often see the red error in Powershell console? Write-Error command helps to prepare your custom error and display in Powershell console. Like a Write-Warning command, Write-Error also can be more advanced with “try{} catch{}” command.
Write-Error -Message "My Custom error message"

Conclusion
The list above will help you prepare output in your scripts or Powershell console. You can test all the commands above just now in your Powershell console. Which of the above commands do you use most often?