17 November,2022 by Tom Collins
Question: I have a SQL Server Agent job in a disabled status. The disabled status is applied to the SQL Agent Job and the associated schedule. The problem is I'm logged on as a full administrator onto the Windows Server - and as BUILTIN\Administrator is defined on the SQL Server , but am able to manually override the SQL Agent Job.
Is there a way to Disable the SQL Agent Job where I'm not able to manually override the job?
Answer: There is no way to disable a SQL Agent Job where it cannot be run manually. The disabled option on a SQL Agent Job stops the job running as a SQL Agent scheduled job. I've specified SQL Agent Job because if another schedule tool such as Autosys is used and triggers a script - than the SQL Agent job will be executed .
For example if using SMO through Powershell and start a disabled SQL Agent job in the context of an ID with suitable privileges , then the job will run
[Microsoft.SqlServer.Management.Smo.Agent.Job]$job = ($sqlServer.JobServer.Jobs | ? { $_.Name -eq 'MySQLAgentJob' });
$job.Start();
There are certain strategies you could apply :
1) Review access to the elevated ID privilege
2) Delete the Job
3) Amend in some way for the job to fail
Read more on managing SQL Agent
List enabled status of SQL Server Agent Jobs
How to check if SQL Server Agent is running using t-sql
How to schedule a SQL Server Agent Job to execute once a year ...
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |