Avatar of Lofty Worm
Lofty WormFlag for United States of America

asked on 

Call other programs from inside Powershell script

I want to pull the raid information in an inventory script, how would I call an exe or bat file from inside the script?
Scripting LanguagesPowershell

Avatar of undefined
Last Comment
Lofty Worm
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

you would just call it like you normally would

For example
$results = ping.exe server1

What command are you trying to use?
Avatar of Lofty Worm
Lofty Worm
Flag of United States of America image

ASKER

lets say a batch file

***Hello.bat***********
echo hello world!
***********
I would like this integrated into the output of the script, maybe concatenate it to the end of the csv file9would that work?) or something.

of coarse the exe bat is more complex, but it will take time to work out the command.
ASKER CERTIFIED SOLUTION
Avatar of BSonPosh
BSonPosh
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Lofty Worm
Lofty Worm
Flag of United States of America image

ASKER

@BSonPosh
:( my test worked, but when I put this in the script, I am getting an error;

dell_raid_info.bat
************
ping.exe localhost
*************


The term 'c:\inventory\dell_raid_info.bat' is not recognized as a cmdlet, function, operable program, or script file. V
erify the term and try again.
At C:\invetory\inventory5.ps1:61 char:51
+     $commandResult=c:\inventory\dell_raid_info.bat <<<<
Avatar of Lofty Worm
Lofty Worm
Flag of United States of America image

ASKER

Ok, I got the batch working, but it is proving more difficult then.  so How would I call just an exe?  like psexec.exe?
Avatar of Lofty Worm
Lofty Worm
Flag of United States of America image

ASKER

as an aside, I got the batch to run with cmd /c dell_raid_info.bat
Scripting Languages
Scripting Languages

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

30K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo