Octopus -- Handle a SQL Job

10/01/2016 17:44
 
#Octopus -- Disable a SQL Job 
#=================================================
$SrssTargetServer = $OctopusParameters['SrssTargetServer']
$SQLJobName = $OctopusParameters['SQLJobName']
 
$str = "SQLCMD -S " + $SrssTargetServer + " -Q ""exec msdb..sp_update_job @job_name = '" + $SQLJobName +"',@enabled = 0"""
 
write-host $str 
 
Invoke-Expression $str
 
 
#Octopus -- Execute a SQL Job 
#=================================================
$SrssTargetServer = $OctopusParameters['SrssTargetServer']
$SQLJobName = $OctopusParameters['SQLJobName']
 
 
$str = "SQLCMD -S " + $SrssTargetServer + " -Q ""exec msdb..sp_start_job '" + $SQLJobName +"'"""
 
write-host $str 
 
Invoke-Expression $str