Skip to content

Commit 4402eae

Browse files
committed
Merge pull request #111 from PowerShell/BugFixes
Push the missing documentation to Master
2 parents 57a7719 + 1ea6a31 commit 4402eae

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#AvoidUsingWriteHost
2+
**Severity Level: Warning**
3+
4+
5+
##Description
6+
7+
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.
8+
9+
##How to Fix
10+
11+
PTo fix a violation of this rule, please replace Write-Host with Write-Output.
12+
13+
##Example
14+
15+
Wrong:
16+
17+
```
18+
function Test
19+
{
20+
...
21+
Write-Host "Executing.."
22+
}
23+
```
24+
25+
Correct:
26+
27+
```
28+
function Test
29+
{
30+
...
31+
Write-Output "Executing.."
32+
}
33+
34+
function Show-Something
35+
{
36+
Write-Host "show something on screen";
37+
}
38+
```

0 commit comments

Comments
 (0)