Skip to content

Added documentation for AvoidUsingWriteHost #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions RuleDocumentation/AvoidUsingWriteHost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#AvoidUsingWriteHost
**Severity Level: Warning**


##Description

It is generally accepted that you should never use Write-Host to create any script output whatsoever, unless your script (or function, or whatever) uses the Show verb (as in, Show-Performance). That verb explicitly means “show on the screen, with no other possibilities.” Like Show-Command.

##How to Fix

PTo fix a violation of this rule, please replace Write-Host with Write-Output.

##Example

Wrong:

```
function Test
{
...
Write-Host "Executing.."
}
```

Correct:

```
function Test
{
...
Write-Output "Executing.."
}

function Show-Something
{
Write-Host "show something on screen";
}
```