Reporting Services and Scriptomatic

Saturday, February 19, 2005

This week I’m going to tie up some lose strings from my VSLive! presentation…

One can programmatically interact with Reporting Services across the network by sending requests via an URL, via a web service request (SOAP), and via Windows Management Instrumentation (WMI). Of these three – I spend no time covering WMI because it’s typically not an interface used to deliver features to end users. I’ll provide some more information here.

In general, WMI exposes classes to configure and mange both hardware and software on computers throughout the network. Reporting Services provides WMI classes that let us query and make changes to report server configurations.

WMI is one of those pieces of software that requires a reference manual nearby unless you work with it everyday, but there is a very easy way to get started: Scriptomatic 2.0. Just pick a WMI class and the tool will code-gen a runnable sample script in VBScript, Jscript, Python, or Perl. Scriptomatic itself is an interesting application written as a single HTA file and run in IE.

Here is a script from Scriptomatic showing the properties of the MSReportServer_ConfigurationSetting class from the root\Microsoft\SqlServer\ReportingServices\v8 namespace:

On Error Resume Next

 

Const wbemFlagReturnImmediately = &h10

Const wbemFlagForwardOnly = &h20

 

arrComputers = Array("REPORTING")

For Each strComputer In arrComputers

   WScript.Echo

   WScript.Echo "=========================================="

   WScript.Echo "Computer: " & strComputer

   WScript.Echo "=========================================="

 

   Set objWMIService = GetObject("winmgmts:\\" & strComputer & _

            "\root\Microsoft\SqlServer\ReportingServices\v8")

   Set colItems = objWMIService.ExecQuery _

           ("SELECT * FROM MSReportServer_ConfigurationSetting", "WQL", _

            wbemFlagReturnImmediately + wbemFlagForwardOnly)

 

   For Each objItem In colItems

      WScript.Echo "DatabaseIntegratedSecurity: " & _

                       objItem.DatabaseIntegratedSecurity

      WScript.Echo "DatabaseLogonName: " & objItem.DatabaseLogonName

      WScript.Echo "DatabaseLogonPassword: " & objItem.DatabaseLogonPassword

      WScript.Echo "DatabaseLogonTimeout: " & objItem.DatabaseLogonTimeout

      WScript.Echo "DatabaseName: " & objItem.DatabaseName

      WScript.Echo "DatabaseQueryTimeout: " & objItem.DatabaseQueryTimeout

      WScript.Echo "DatabaseServerName: " & objItem.DatabaseServerName

      WScript.Echo "Impersonate: " & objItem.Impersonate

      WScript.Echo "ImpersonateDomain: " & objItem.ImpersonateDomain

      WScript.Echo "ImpersonatePassword: " & objItem.ImpersonatePassword

      WScript.Echo "ImpersonateUserName: " & objItem.ImpersonateUserName

      WScript.Echo "InstallationID: " & objItem.InstallationID

      WScript.Echo "InstanceName: " & objItem.InstanceName

      WScript.Echo "PathName: " & objItem.PathName

      WScript.Echo "UnattendedExecutionLogonDomain: " & _

                      objItem.UnattendedExecutionLogonDomain

      WScript.Echo "UnattendedExecutionLogonName: " & _

                      objItem.UnattendedExecutionLogonName

      WScript.Echo "UnattendedExecutionLogonPassword: " & _

                      objItem.UnattendedExecutionLogonPassword

      WScript.Echo "VirtualRoot: " & objItem.VirtualRoot

      WScript.Echo

   Next

Next

 

 

If you’d rather have the code in .NET, then the System.Management namespace contains all the WMI goo. WMI is probably underutilized due to the quirky mixture of SQL like syntax with a namespace traversed like a file system. It seems powerful, and it’s something I need to keep in mind next time I need a configuration script.


Comments
Milan Negovan Sunday, February 20, 2005
I agree that WMI is underutilized. Back in the day of desktop development I was shocked how much information I could coax out of the system (even via plain scripting, not even C++) as opposed to chasing Platform SDK for APIs.
John Sunday, February 20, 2005
Everyone should have the Windows 2000 Scripting Guide [1].
<br>
<br>John.
<br>
<br>[1] http://www.amazon.com/exec/obidos/tg/detail/-/0735618674/
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!