In this short post, we’ll see how we can prevent a PowerShell cmdlet from printing anything to the std output stream. There are two ways you can do this.
- Piping the output of the cmdlet to Out-Null
e.g. Set-AzureRmContext -SubscriptionId "SubId" | Out-Null
- Assigning the output of the cmdlet to $null
e.g. $null = Set-AzureRmContext -SubscriptionId "SubId"
Either of these would prevent the output being printed to the output stream.
P.S. I learned this today and would love to know if there are more ways to achieve the same 🙂
Hope this helps!