none
Invoke-Command to Multiple machines with Multiple Credentials RRS feed

  • Question

  • Hi,

    Does anyone know of a simple way of using Invoke-Command with multiple credentials. Looking at the Invoke-Command it seems that its because the -Credentials property does not accept arrays, only the -Computer property does.

    $Job = Invoke-Command $MachineNames.Name -Credential $MachineNames.Credentials { "Hello from $(Hostname)" } -AsJob

    The only thought I have at the moment, is to split the machines up into batches with the same credentials. Just wondering if there's a more elegant way of doing it though?

    Wednesday, January 4, 2017 2:34 PM

Answers

  • There is no way to add multiple credentials to any command.  You have to execute each command in a loop with explicit credentials as needed.

    \_(ツ)_/

    • Proposed as answer by Hello_2018Moderator Thursday, January 5, 2017 4:41 AM
    • Marked as answer by KayTannee Thursday, January 5, 2017 5:34 AM
    Wednesday, January 4, 2017 3:13 PM
    Moderator

All replies

  • There is no way to add multiple credentials to any command.  You have to execute each command in a loop with explicit credentials as needed.

    \_(ツ)_/

    • Proposed as answer by Hello_2018Moderator Thursday, January 5, 2017 4:41 AM
    • Marked as answer by KayTannee Thursday, January 5, 2017 5:34 AM
    Wednesday, January 4, 2017 3:13 PM
    Moderator
  • Thank you, it helps knowing that there's not an alternative way to do it.


    Thursday, January 5, 2017 7:34 AM