Best Practice: Remote Commands

This topic contains 3 replies, has 3 voices, and was last updated by  Des Davies 3 months ago.

  • Author
    Posts
  • #93535

    Des Davies
    Participant

    Is there a best practice for running cmdlets against a remote computer?

    For example:

    Get-NetAdapter -CimSession $Session ...
    Invoke-Command -ComputerName $Session -Scriptblock { Get-NetAdapter }

    Is either of these "better" than the other, or does it come down to personal preference?

    Thanks,
    Des

  • #93579

    Don Jones
    Keymaster

    Those use slightly different protocols. Aside from that, the former doesn't work in Core, I don't think.

    • #93588

      js
      Participant

      Core has new-cimsession (windows only). Core doesn't have get-netadapter.

  • #93589

    Des Davies
    Participant

    Thanks. Going to rework a few modules to use only the ICM then.

You must be logged in to reply to this topic.