Best Practice: Remote Commands

Welcome Forums General PowerShell Q&A Best Practice: Remote Commands

This topic contains 3 replies, has 3 voices, and was last updated by

 
Participant
9 months, 1 week ago.

  • Author
    Posts
  • #93535

    Participant
    Points: 0
    Rank: Member

    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

    Keymaster
    Points: 1,639
    Helping HandTeam Member
    Rank: Community Hero

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

    • #93588
      js

      Participant
      Points: 224
      Helping Hand
      Rank: Participant

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

  • #93589

    Participant
    Points: 0
    Rank: Member

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

The topic ‘Best Practice: Remote Commands’ is closed to new replies.