none
Running Remote File.bat with parameters - not working? RRS feed

  • Question

  • Greetings,

    I've been trying for a couple of days to figure out how this work...

    i've tried the following methods to run a specific bat file on a remote machine:

    Invoke-Command -ComputerName <Name> -ScriptBlock {& 'Path\File.bat -Parameter'}

    Invoke-Command -ComputerName <Name> -ScriptBlock {& 'Path\File.bat'} -ArgumentList '-Parameter'

    Anyone has any idea?

    Best Regards,

    Slyfer.

    • Moved by Bill_Stewart Friday, March 15, 2019 5:30 PM Unanswerable drive-by question
    Tuesday, January 1, 2019 11:19 AM

All replies

  • What is the error?


    \_(ツ)_/

    Tuesday, January 1, 2019 11:45 AM
  • Error occurred durig initialization of VM

    could not reserve enough space for object heap

    Ive also tried 

    winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1000"}'

    from other posts ive seen, nothing really helped, funny thing is that other command without parameters

    working just fine!

    Best Regards,

    Slyfer

    Tuesday, January 1, 2019 12:42 PM
  • What is the exact and complete first error message?

    Changing memory settings is not necessary as PS is set for 3Gb by default. Yu just set it to less.

    Default is: 2,147,483,647

    I suspect you bat is running an endless loop so you need to debug that first.


    \_(ツ)_/

    Tuesday, January 1, 2019 12:56 PM
  • my bat isnt an endless look, its a command from another software which i run from a local PS script i created.

    which is working just fine...

    but instead of being dependent on remote script, i want to run the command remotely...

    Best Regards,

    Tal.

    Tuesday, January 1, 2019 1:01 PM
  • Your post is not very helpful.  The issue is not caused by PowerShell it is caused by the software you are trying to run.  Contact the vendor to find out if it is compatible with remoting.  It clearly has issues.


    \_(ツ)_/

    Tuesday, January 1, 2019 1:16 PM
  • I have done something similar to this. I ran a powershell script remotely on a server.

    Invoke-Command -ComputerName <name> -ScriptBlock {powershell.exe -ExecutionPolicy ByPass -File c:\temp\mypsscript.ps1}

    Instead of batch file, you can run it as powershell script on the server.


    • Edited by RATG Friday, January 11, 2019 5:02 AM
    Friday, January 11, 2019 4:59 AM