Click an Ad

If you find this blog helpful, please support me by clicking an ad!

Friday, June 14, 2013

Running Scheduled Reports in Spiceworks

We love Spiceworks! BUT it's still missing some things. One of which is the ability to set up reports to run automatically and email them to you. Well, it's not missing per se, it's just kind of complicated. The ability is there, and this is how to use it.

The post here within the Spiceworks Community got me started, but I wanted to show the whole picture.

On your Spiceworks server, go to c:\Program Files (x86)\Spiceworks and create a new folder called 'rpt'.

Now go into c:\Program Files (x86)\Spiceworks\pkg\gems\spiceworks-X.X.XXXXX (where the X's represent your version number), and copy the file run_report.rb into the rpt folder you created in step 1.

Open a command prompt and navigate to c:\Program Files (x86)\Spiceworks\rpt and execute the following command to see how to use this ruby script:

..\bin\ruby run_report.rb -?

Now, you need to find the report number that corresponds to the report you want to run. In my case, I used the following command:

..\bin\ruby run_report.rb -e user@contoso.com -p password -l

Your Spiceworks login credentials are used in the above command, as well as -l, which lists all reports, along with their report numbers. Write down the report numbers you want.

In a batch file, write a line for each report. Here is an altered copy of my batch file:

Now, go into Task Scheduler and create a task to run the batch file. The batch file creates the reports, which output into pdf and are stored in the rpt folder we create. Then, the batch file calls the Powershell script which emails these files as attachments and then deletes the PDF files that were created.

I had some issues getting Powershell scripts to run as scheduled tasks as well. I was never able to figure out why, so what I ended up doing was making a domain admin account that runs all of my scripts. That worked. If you find out why, let me know please.