goodmanjl531 Posted July 27, 2021 Share Posted July 27, 2021 (edited) I am trying to run a powershell script elevated that will add a new printer port. the powershell script works fine when call from an elevated command prompt but I can't seem to call this via auto it. Local $sUserName = "" ; Place Admin User ID here. Local $sPassword = "" ; Place Admin Password here. #include <Date.au3> SplashTextOn(" Inc.","Running Printer IP update Please Wait.....","-1","-1","-1","-1",0,"","","") _WriteLog("Installation Started : ") FileInstall("C:\TS\CloudScripts\Reconfigure-Printer-V0.5.ps1","C:\ts\Reconfigure-Printer-V0.5.ps1",1) $Result = RunAsWait($sUserName, @ComputerName, $sPassword, 0,@ComSpec & " /c " & 'powershell.exe -file Reconfigure-Printer-V0.5.ps1', "", @SW_HIDE) _WriteLog("POWERSHELL SCRIPT RAN : " & $Result) ;$Result=RunAsWait($sUserName, @ComputerName, $sPassword, 0, "powershell.exe -file Reconfigure-Printer-V0.5.ps1"); Run Powershell script to rest printer ;_WriteLog("CBTS Powersehll script executed :"& $Result) Sleep(5000) _WriteLog("Installation Completed: ") SplashOff() SplashTextOn(" Inc.","Printer RE-IP Complete","-1","-1","-1","-1",0,"","","") Sleep(5000) SplashOff() Func _WriteLog($Message) FileWriteLine(@ScriptDir & "\" & @ScriptName & ".log", @YEAR & @MON & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & ": " & $Message) EndFunc ;==>_WriteLog Edited July 27, 2021 by goodmanjl531 Link to comment Share on other sites More sharing options...
Solution goodmanjl531 Posted July 28, 2021 Author Solution Share Posted July 28, 2021 was able to find answer.. RunAsWait($sUserName, @ComputerName, $sPassword, 0, "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy Bypass -file c:\ts\Reconfigure-Printer-V0.5.ps1") 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