to Run a bat file remotely

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Daniel Krebs Daniel Krebs 3 weeks, 5 days ago.

  • Author
    Posts
  • #69595
    Profile photo of Srikanth Byram
    Srikanth Byram
    Participant

    i have a application which need to be updated via a bat file .

    i'm looking for a powershell cmdlet or using psexec command to run this bat file on remote machines please help

    tried with start-process and psexec command which doesn't help me .

  • #69598
    Profile photo of Daniel Krebs
    Daniel Krebs
    Moderator

    I'll want to use the Invoke-Command cmdlet.

    Example:

    param (
      [Parameter(Mandatory=$true)]
      [String[]]
      $ComputerName
    )
    
    Invoke-Command -ComputerName $ComputerName -ScriptBlock {
      & 'C:\path to file\name.bat'
    }
    

    Documentation:
    https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/invoke-command

You must be logged in to reply to this topic.