Skip to content

Commit 5691c9a

Browse files
committed
Added markdown for AvoidUsingWriteHost rule
1 parent e99e88d commit 5691c9a

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
Correct:
25+
'''
26+
function Test
27+
{
28+
...
29+
Write-Output "Executing.."
30+
}
31+
32+
function Show-Something
33+
{
34+
Write-Host "show something on screen";
35+
}
36+
37+
'''

0 commit comments

Comments
 (0)