最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

sql server - Why is my SQL Agent job powershell command not working? - Stack Overflow

programmeradmin4浏览0评论

I am trying to use a SQL agent job to trigger start another job on another SQL server.

Currently have some on-prem servers and some VM's with SQL Server in Azure. This powershell command is working as expected between the on-prem servers but when executing on an on-prem server to trigger an agent job on one of the azure servers, it doesn't trigger the job. Instead it 'Quits with Success' with the following output:

Message

Executed as user: DOMAIN\sysadminuser. The step did not generate any output. Process Exit Code 0. The step succeeded.

Command:
$ServerName="SQL_On_AzureVM_ServerName" 
$JobName="Test"


[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SMO') | out-null

$srv = New-Object Microsoft.SqlServer.Management.SMO.Server("$ServerName")
$job = $srv.jobserver.jobs["$JobName"] 

if ($job)
{        
 
                 $job.Start()
 
                   $i = 0
}
发布评论

评论列表(0)

  1. 暂无评论