Execute a batch file on a remote server

Welcome Forums General PowerShell Q&A Execute a batch file on a remote server

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

 
Participant
3 years, 5 months ago.

  • Author
    Posts
  • #24549

    Participant
    Points: 0
    Rank: Member

    Just looking for some tips on writing a script to execute a batch file on a remote server. I don't to use the PsExec tool as I want users to be able to run the script easily.
    I read on a technet forum that you create a process using an object to execute the batch file.

    Thanks!

  • #24550

    Moderator
    Points: 0
    Rank: Member

    Hi Byron,

    Please check out the Invoke-Command cmdlet to run scripts on one or more remote servers.

    Get-Help Invoke-Command
    Get-Help Invoke-Command -Examples
    

    https://technet.microsoft.com/en-us/library/hh849719.aspx

    Invoke-Command -ComputerName MyRemoteServer -ScriptBlock { $env:COMPUTERNAME }
    

    Best,
    Daniel

    • #24620

      Participant
      Points: 0
      Rank: Member

      Hi Daniel

      Will check out the cmdlet!

      Thanks!

The topic ‘Execute a batch file on a remote server’ is closed to new replies.