Databases Reference
In-Depth Information
Creating Scripts
Many repetitive tasks on Report Server administration and management can be automated using script
files. An example that was covered in the last topic is managing subscriptions. You can also copy reports
from one server to another and then schedule the script to run when network traffic is low. By using
scripts, the security configuration can be updated on a remote machine, or the settings of a single report
can be copied to multiple reports on a server — or across a server farm.
Reporting Services provides a WMI interface to the configuration files for the Report Server instance and
the Report Manager application. Much like the command-line utilities, these classes provide a way to
programmatically perform application management. For example, you can change the credential values
and authentication mechanisms that the Report Server uses to connect to the database. The same classes
can be used to perform actions on remote machines.
As you may know, the configuration files are XML files. The next time the application runs, the .NET
Common Language Runtime (CLR) will apply the new values in the configuration file. The Report Server
configuration file is programmatically accessed through the MSReportServer_ConfigurationSetting
class, and the Report Manager Interface web application configuration file is available through the
MSReportServerReportManager_ConfigurationSetting class. Both classes are accessed through the
WMI interface.
Script files can be created using a text editor, Visual Studio, or SQL Server Management Studio. The file
that contains the automation code is a Unicode or UTF-8 text file with a .rss file extension. The code
itself is written in VB. We'll cover automatically generated scripts at the end of this chapter; in the mean-
time, let's look at how to build your own.
Using the RS WMI Provider
Invoking the RS utility is as simple as typing rs or rs.exe at the command prompt and supplying the
required values. The two required values are the script to run ( /i argument) and the server to run the
script against ( /s argument).
The syntax for using the RS utility is:
rs / i <inputFile> / s <serverURL> [/ u <username>] [/ p <password>] [/ l <timeout>]
[/ b ] [/v <var=value>] [/ t ]
The arguments (parameters) can be indicated by using the / or - symbols. For example, the input file
value can be provided using -i or /i and the filename. It's a matter of personal preference and, in some
cases, the company style guide. The arguments themselves are case insensitive except for the password
value. You can have as many spaces as you want between the argument indicator and the value you're
providing.
The script file must be a fully qualified path to the rss file. For example, let's say that your scripts are
located in the C:\ReportServer\Scripts directory. If you navigate to that location in the command
window, the path value that you'll provide to the RS utility will be as simple as the filename itself.
The serverURL value is made up of the protocol, server, and virtual directory to execute the script. By
default, the RS utility will attempt to connect to the resource using https . If you specify http , the RS
Search WWH ::




Custom Search