PnoT Posted May 28, 2009 Posted May 28, 2009 I'm trying to get this script to run a powershell command on a remote server so i can give executive admins in our company an easy way to setup anyone with out of office. I believe I'm passing the input variables wrong at the end because i have verified the script launches the powershell.exe on the remote system. The arguments for the powershell script are: PowerShell.exe <pathToScript>\set-OOf.ps1 <Primary SMTP Address of User> OOf Message (notice the ' ' on the last argument) Here is my script so far... $email = InputBox("Out of Office Tool", "Email address of employee?") $message = InputBox("Out of Office Tool", "Message to be displayed in Out of Office Message?") run("psexec \\servername -d -u username -p password -w c:\oofscript\ ""powershell.exe c:\oofscript\set-oof.ps1"" & $email & $message")
Developers Jos Posted May 28, 2009 Developers Posted May 28, 2009 (edited) run("psexec \\servername -d -u username -p password -w c:\oofscript\ ""powershell.exe c:\oofscript\set-oof.ps1"" " & $email & " '" & $message & "'") Edited May 28, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
PnoT Posted May 28, 2009 Author Posted May 28, 2009 run("psexec \\servername -d -u username -p password -w c:\oofscript\ ""powershell.exe c:\oofscript\set-oof.ps1"" " & $email & " '" & $message & "'") I ran the code that you've posted but now the powershell.exe is not showing up on the remote server as a process anymore so it's acting like no execution is being done.
Developers Jos Posted May 28, 2009 Developers Posted May 28, 2009 (edited) I didn't check your whole commandline before but it looks like you had a double quote at the wrong place. Try this version: run("psexec \\servername -d -u username -p password -w c:\oofscript\powershell.exe ""c:\oofscript\set-oof.ps1"" " & $email & " '" & $message & "'") Edited May 28, 2009 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Developers Jos Posted May 28, 2009 Developers Posted May 28, 2009 To check if the real command is looking correct you could also run something like this from SciTE: Consolewrite("psexec \\servername -d -u username -p password -w c:\oofscript\powershell.exe ""c:\oofscript\set-oof.ps1"" " & $email & " '" & $message & "'") ConsoleWrite(@crlf) SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
PnoT Posted May 28, 2009 Author Posted May 28, 2009 I didn't check your whole commandline before but it looks like you had a double quote at the wrong place. Try this version: run("psexec \\servername -d -u username -p password -w c:\oofscript\powershell.exe ""c:\oofscript\set-oof.ps1"" " & $email & " '" & $message & "'") That fixed things for me! Thank you very much for the assistance and super quick response. You've gotta love a forum where a developer takes the time out of his/her busy schedule to lend a helping hand.
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