Search code examples
powershellaws-powershell

How can I redirect this output to $null?


I'm using the AWS Powershell tools.

When I run the following, I get a message from the cmdlet.

(Set-AWSCredentials -AccessKey $key -SecretKey $secret -StoreAs "default") > $null

I get the following message:

INFO: Credentials loaded from the supplied key parameters

How can I prevent this message from being written to the host? I attempted redirecting using *> as well, yet the message remains.


Solution

  • The cmdlet seems to write that info message to the host program. Something like this might work:

    powershell -Command "Set-AWSCredentials -AccessKey '$key' -SecretKey '$secret' -StoreAs 'default'" >$null
    

    When you run a command in a separate host program, the host output of that program appears in the success output stream of its parent host program.