February 2019
Intermediate to advanced
626 pages
15h 51m
English
The Out-Null command can be used at the end of a pipeline to discard the output from a statement.
The Out-Null command is relatively unpopular in Windows PowerShell as it is slow. In PowerShell Core, the speed issue is resolved, since Out-Null is one of the fastest—if not the fastest—of the available options.
Sticking with the StringBuilder example, the unwanted value might have dropped by appending Out-Null, as shown here:
using namespace System.Text$stringBuilder = [StringBuilder]::new()$stringBuilder.AppendFormat('Name: {0}', $service.Name).AppendLine(). AppendFormat('Status: {0}', $service.Status).AppendLine(). AppendLine() | Out-Null$stringBuilder.ToString()
One criticism that might be leveled against Out-Null is ...
Read now
Unlock full access