executing remote script on remote machine from my PC

Welcome Forums General PowerShell Q&A executing remote script on remote machine from my PC

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

1 year, 11 months ago.

  • Author
  • #72926

    Topics: 1
    Replies: 0
    Points: 0
    Rank: Member

    Hi all,

    im having some issues with firing up a script saved on a remote machine from my PC.
    the script will finish customizing a freshly cloned VM (Remote Desktop Session-Host).
    i have the MasterScript on my PC and all SubScripts are located on the remote server.
    so i run this (the workflow is a mock-up just to show there is a workflow in use):

    workflow customize
      foreach -parallel ($VM in $VMs)
         Invoke-VMScript -VM $T_VMNewName -ScriptText 'C:\Scripts\AddToBroker.ps1' -GuestCredential $Credentials_Domain

    but i cant get it to work with domain admin creds so the script fails...

    so i try this (in the workflow):

    $session = New-PSSession -ComputerName $T_VMNewName -Credential $Credentials_Domain
    Invoke-Command -Session $session -command {"C:\Scripts\AddToBroker.ps1"}

    but i get: The RD Connection Broker server is not available. Verify that you can connect to the RD Connection Broker server.
    if i run the script locally on the remote machine – it works booli (that mean perfect)

    any tips would be appreciated 🙂



  • #72931

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    Bear in mind that when you remote into a machine, you (a) don't get a full interactive user session and (b) can't delegate your credentials from the remote machine to anyplace else, unless you've taken extra configuration steps. It's likely you're running into one or both of these things. Either the script you're trying to run _needs_ a full interactive user session for something it's doing, or it needs to connect to some network service that's demanding a security token, and your delegated token can't be delegated any further.

    "Secrets of PowerShell Remoting" (free on our ebooks menu) discusses that latter, 'second hop' problem. I don't know if the RD Session Broker can be configured to accept CredSSP, for example, so it's possible you're S.O.L. (That means "not lucky") in terms of executing this the way you are.

  • #72991

    Topics: 0
    Replies: 11
    Points: 0
    Rank: Member

    Check all of your remote hosts are added to TrustedHosts in the local host??

    gci WSMan:\localhost\Client\TrustedHosts

The topic ‘executing remote script on remote machine from my PC’ is closed to new replies.

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