Execute a batch file on a remote server

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Byron Grogan Byron Grogan 1 year, 11 months ago.

  • Author
    Posts
  • #24549
    Profile photo of Byron Grogan
    Byron Grogan
    Participant

    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
    Profile photo of Daniel Krebs
    Daniel Krebs
    Participant

    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
      Profile photo of Byron Grogan
      Byron Grogan
      Participant

      Hi Daniel

      Will check out the cmdlet!

      Thanks!

You must be logged in to reply to this topic.