You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The PowerShell style guidelines now include comprehensive guidance on
suppressing unwanted output from commands and methods. This addition
helps developers choose the most performant approach when they need to
discard function or method return values.
- Fixes#224
## Suppressing Output Section
A new section has been added to the PowerShell style guidelines
(`pwsh.instructions.md`) that provides clear guidance on:
- **Using `$null =` for best performance** - The recommended approach
for suppressing output from both cmdlets and .NET method calls
- **Using `[void]` as an alternative** - Another valid option
specifically for method calls that return values
- **Avoiding `| Out-Null`** - Explicitly noting that this approach has
significantly slower performance and should be avoided
The section includes practical examples showing both correct and
incorrect usage patterns, making it easy for developers to follow the
best practices.
## Performance Impact
This guidance is especially important in performance-critical code and
loops, where the overhead of `| Out-Null` can accumulate and cause
noticeable slowdowns. By using `$null =` or `[void]`, developers can
ensure their scripts run efficiently.
0 commit comments