Sign in to follow this  
Followers 0
kor

Running powershell commands from within AutoIt

5 posts in this topic

I have searched and have found ways to call a powershell script from autoit but I don't see anything about how to run powershell scripts from within AutoIt similar to running dos commands using @ComSpec.

any ideas?

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

here is one.

may i recommend a google of "site:autoitscript.com powershell" returns a few more threads (that the internal search does not).

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

I am having issues with syntax I guess. if I execute the following command in a run window it opens without errors. however if I execute the same thing using Run() I get all kinds of powershell errors. Any ideas?

(If anyone could help me format this command into a single var that would be great too. Im dumb with quotes and double quotes)

command -> C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto"

$1 = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command "
$2 = """. "
$3 = "'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'"
$4 = "; Connect-ExchangeServer -auto"

Run($1 & $2 & $3 & $4, '')

I've also tried Run(@Comspec and ShellExecute and nothing works

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

name=]']]

Try:

$1 = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit ' & _
'-command . C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1;' & _
'Connect-ExchangeServer -auto'
Run($1, '')
Edited by JoHanatCent

Share this post


Link to post
Share on other sites

or this?

$cmd = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -command . ' & _
'"C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1"; Connect -ExchangeServer -auto'
MsgBox(0,'',$cmd)

Never used PowerShell, so lack of info on my part, but, what is the dot for?

-command . '


Make yourself sheep and the wolves will eat you - Benjamin Franklin

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0