Link to home
Start Free TrialLog in
Avatar of motioneye
motioneyeFlag for Singapore

asked on

what powershell command to run batch file job

Hi,
I have batch file, how do I use powershell to execute the batch file, something like calling this file btw.bat ?
ASKER CERTIFIED SOLUTION
Avatar of netcmh
netcmh
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Bill Prew
Bill Prew

You should just be able to type the name of the BAT file if it is in a directory in your PATH.  If it is in the current directory then preface it with ".\" as below.

.\foo.bat

~bp
command line:

powershell.exe -noexit .\btw.bat
Avatar of motioneye

ASKER

actually I want to run it within the powershell scripts, so can it be as simple as typing .\foo.bat in the scripts or ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
Ok here is my scripts, the output is not the results which I'm looking for. The bat file contain only ping command.

$servers = get-content "F:\PowerShell_Myscripts\AllServers.txt"
@(ForEach ($server in $servers){
   .\btw.bat
}) | Export-CSV "F:\PowerShell_Myscripts\result.csv" -notype
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I must use bacth file... that the problem.. so how do I proceed
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial