executing remote script on remote machine from my PC

This topic contains 2 replies, has 3 voices, and was last updated by  Kiran P 4 months, 1 week ago.

  • Author
    Posts
  • #72926

    Sean
    Participant

    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)
         InlineScript
         {
         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 🙂

    thanks

    Sean

  • #72931

    Don Jones
    Keymaster

    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

    Kiran P
    Participant

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

    gci WSMan:\localhost\Client\TrustedHosts

You must be logged in to reply to this topic.