File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -11,29 +11,32 @@ Commands with the `Show` verb do not have this check applied.
1111
1212## How
1313
14- Replace ` Write-Host ` with ` Write-Output ` or ` Write-Verbose ` .
14+ Replace ` Write-Host ` with ` Write-Output ` or ` Write-Verbose ` depending on whether the intention is logging or returning one or multiple objects .
1515
1616## Example
1717
1818### Wrong
1919
2020``` PowerShell
21- function Test
21+ function Get-MeaningOfLife
2222{
2323 ...
24- Write-Host "Executing.. "
24+ Write-Host "Computing the answer to the ultimate question of life, the universe and everything "
2525 ...
26+ Write-Host 42
2627}
2728```
2829
2930### Correct
3031
3132``` PowerShell
32- function Test
33+ function Get-MeaningOfLife
3334{
35+ [CmdletBinding()]Param() # to make it possible to set the VerbosePreference when calling the function
3436 ...
35- Write-Output "Executing.. "
37+ Write-Verbose "Computing the answer to the ultimate question of life, the universe and everything "
3638 ...
39+ Write-Output 42
3740}
3841
3942function Show-Something
You can’t perform that action at this time.
0 commit comments