4

I am running the below cmdlet which I need to use in a script.

Connect-Pfa2Array -Endpoint 10.10.10.10 -Username pureapiuser -Password $psw -IgnoreCertificateError

I get the below output which I am trying to suppress. I just need for the cmdlet to make the connection. Is there a way this can be done? I checked the cmdlet and did not see an option to do a silent connection.

ArrayName    ApiVersion
---------    ----------
10.100.24.50 2.2 
1
  • 5
    Try | Out-Null or > $null Commented May 14, 2021 at 20:49

1 Answer 1

6

As Santiago Squarzon mentioned, there are a couple of options you can use:

[void](Connect-Pfa2Array ... )

or

Connect-Pfa2Array | Out-Null

or

Connect-Pfa2Array > $null

or

$null = Connect-Pfa2Array
Sign up to request clarification or add additional context in comments.

3 Comments

Nicely done, though not all of these approaches are created equal; overall, $null = ... is the best general-purpose solution, while | Out-Null should be avoided for performance reasons - see this answer to a closely related question.
@mklement0 I like you mention not using the pipeline alternative for efficiency, it's hard for me to understand why do newcomers to PS (including myself at some point) get obsessed with using pipeline alternatives everywhere they can when there are more classic and efficient approaches of doing things :P
@SantiagoSquarzon, that is understandable, given that the pipeline is a very elegant concept, and it would be great if it didn't carry a performance penalty, but it invariably does (at least as currently implemented; conceivably, PowerShell could convert purely expression-based pipelines into more efficient constructs behind the scenes); conversely, the pipeline enables memory-efficient, streaming solutions (unless the result is collected in memory in full in the end anyway).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.