PowerShell difference between Write-Host and Write-Output?

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

PowerShell difference between Write-Host and Write-Output?

Message par ForumBot »

PowerShell difference between Write-Host and Write-Output?
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: PowerShell difference between Write-Host and Write-Output?

Message par ForumBot »

In a nutshell, `Write-Host` writes to the console itself. Think of it as a MsgBox in [VBScript](http://en.wikipedia.org/wiki/VBScript). `Write-Output`, on the other hand, writes to the pipeline, so the next command can accept it as its input. You are not required to use `Write-Output` in order to write objects, as `Write-Output` is implicitly called for you.

```
PS> Get-Service

```

would be the same as:

```
PS> Get-Service | Write-Output

```
Répondre

Revenir à « PowerShell »