remote invoke question

Welcome Forums General PowerShell Q&A remote invoke question

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

5 years, 8 months ago.

  • Author
  • #6973

    Points: 0
    Rank: Member

    3 pc in one workgroup:pc1,pc2,pc3, all have ps v2.0
    in scriptA,pc1 use invoke-command to send a scriptB to pc2,3.
    scriptB will change pc2,3's ip address.

    how can i know which pc's set is ok or failed?
    how does invoke-command ensure send script to which pc is ok?

  • #6977

    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    If there are errors, they'd be returned to PC1.

  • #6978

    Points: 0
    Rank: Member

    thanks Donl,
    but when run scriptA,after invoke-command,
    the powershell console wait a long time to end . (2 pc used about 4 min)
    in the last it tell me ,get data from remote serve failed.
    of course,the ip is changed.
    how can pc2/3 tell pc1 don't wait for more data ?

  • #6984

    Points: 1
    Rank: Member

    Some ideas to consider: Instead of invoking the command to change the IP address inside of the remoting session, you can create a new PowerShell process to change the IP address using Start-Process (that is, by invoking Start-Process inside of the Invoke-Command script block). That would allow you to remotely start a secondary PowerShell process and then return immediately to pc1. In your secondary PowerShell process you can change the IP address. To make sure that the IP address does not change before Invoke-Command returns to PC1, you could add a call to start-sleep just to give the remote command enough time to finish and close the session.

  • #6999

    Points: 0
    Rank: Member

    thanks Poshoholic!

    i a beginner in script programming,your advice have great value to me!
    But how to write this command about your advice?

    pc1 send script to pc2,3 with some arguments to run
    (such as [hashtable]$hm=@{pc2="aaa";pc3="bbb"})
    pc2,3 find itself information from input arguments

    It's too difficult for me,i will think about it later.

The topic ‘remote invoke question’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort