Jump to content

Running powershell commands from within AutoIt


kor
 Share

Recommended Posts

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?

Link to comment
Share on other sites

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

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

Link to comment
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

Link to comment
Share on other sites

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
Link to comment
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 . '

"The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...