January 28, 2022 at 5:43 am
Hi All ,
I need to run powershell script which is located in other server, lets say server A . In server B , i created the SQL job ..
What is the query that I need to put in Command area so I can run it as ( ABC\xxx ) and execute the script using that account ?
type : powershell
script location : \\serverA\D$\folderA\script.ps1
default : running as sql server agent account
i tried : runas /user:ABC\xxx "\\serverA\D$\folderA\script.ps1”
the outcome of sql job is asking the password which is not what i expect …
i expect to see Hello world as it is written in my simple script
please kindly help
thank you
January 28, 2022 at 9:00 pm
You need to create a credential in SQL Server for the domain account ABC\xxx. Once that is created - create a proxy account for the appropriate subsystem (Powershell or Operating System).
For the agent job step, you can then use that Proxy account to run the script.
Note: for a PS script - if it is stored on a network share it must be signed or you need to set the execution policy on the command line.
powershell.exe -command "try { & \\serverA\D$\folderA\script.ps1} catch {throw $_}"
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
February 1, 2022 at 9:27 pm
Hi Jeff
thanks so much for the response
How do I tell SQL to use that proxy account to run the script ?
there is no option “run as “if i choose type : powershell in SQL job
unless the type is Transact SQL
February 1, 2022 at 11:37 pm
I need to run powershell script which is located in other server, lets say server A .
I'm curious... what does the PowerShell script actually do?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply