Q:

Can SSRS reports triggered from Shell scripts?

Can we trigger the SSRS reports using a shell scripting language. I am aware about RS.exe will it be useful in the triggering the SSRS report thru Shell script?
Thanks in Advance.

A:

You can trigger report subscriptions through SQL, so I would imagine you can do that through a shell script.
The report subscriptions are jobs on the server, so you need to know the jobID for it to work. You can then trigger with:
use msdb;
exec sp_start_job @job_name = '';

job_name comes from the table dbo.Schedule in the ReportServer database.  You can use something like this script to find it out:
declare @SearchString as nvarchar(100) = '';

with [SubscriptionXML] as 
(
    select 
        sb.SubscriptionID,
        cast(sb.ExtensionSettings as xml) as [ExtensionSettingsXML]
    from dbo.Subscriptions as [sb]
    inner join dbo.[Catalog] as [c] on sb.Report_OID = c.ItemID
where c.[Name] like '%' + @SearchString + '%'
),
[SettingsCTE] as 
(
    select 
        sxml.SubscriptionID,
        isnull([xml].Settings.[value]('(./*:Name/text())[1]', 'nvarchar(1024)'), 'Value') as [SettingName],
        [xml].Settings.[value]('(./*:Value/text())[1]', 'nvarchar(max)') as [SettingValue]
    from [SubscriptionXML] as [sxml]
        cross apply sxml.ExtensionSettingsXML.nodes('//*:ParameterValue') as [xml](Settings)
)
select
     s.ScheduleID as [SQLAgentJobName],
     c.[Name] as [ReportName],
     scteSubject.SettingValue as [Subject],
     scteTo.SettingValue as [To],
     scteBCC.SettingValue as [BCC],
     case s.RecurrenceType
        when 1
            then 'Once'
        when 2
            then 'Hourly'
        when 3
            then 'Daily'
        when 4
            then 'Weekly'
        else 'Monthly'
    end as [SubscriptionScheduleType],
    c.[Path] as [ReportPath],
    s.[LastRunTime]
from dbo.ReportSchedule as [rs]
    inner join dbo.Schedule as [s] on s.ScheduleID = rs.ScheduleID
    inner join dbo.[Catalog] as [c] on c.ItemID = rs.ReportID
    left join [SettingsCTE] as [scteSubject] on scteSubject.SubscriptionID = rs.SubscriptionID
        and scteSubject.SettingName = 'Subject'
    left join [SettingsCTE] as [scteTo] on scteTo.SubscriptionID = rs.SubscriptionID
        and scteTo.SettingName = 'To'
    left join [SettingsCTE] as [scteBCC] on scteBCC.SubscriptionID = rs.SubscriptionID
        and scteBCC.SettingName = 'BCC'
where c.[Name] like '%' + @SearchString + '%';

Once you have that job_name you can just refer to it in your shell script. All you would need to do then is to trigger the bit of SQL for sp_start_job from your script. 

