kor Posted January 14, 2011 Share Posted January 14, 2011 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 More sharing options...
iamtheky Posted January 14, 2011 Share Posted January 14, 2011 (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 January 14, 2011 by iamtheky ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
kor Posted January 14, 2011 Author Share Posted January 14, 2011 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 More sharing options...
JoHanatCent Posted January 15, 2011 Share Posted January 15, 2011 (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 January 15, 2011 by JoHanatCent Link to comment Share on other sites More sharing options...
ripdad Posted January 15, 2011 Share Posted January 15, 2011 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now