6 the most basic Powershell output commands

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


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 "Poshland"
Write-Host "Poshland" -ForegroundColor Green
$x = Write-Host "Poshland" -ForegroundColor Green
(Write-Host "Poshland" -ForegroundColor Green).GetType()
powershell output commands


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"
powershell output commands


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 -InputObject "Poshland Blog"
$x = Write-Output -InputObject "Poshland Blog"
powershell output commands


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:

 Write-Verbose "My hide output only for verbose mode"
 Write-Output "Script output"
powershell output commands


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"
powershell output commands


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"
powershell output commands


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?

Get Access to Poshland Resources for FREE!!!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailerLite ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.