Automated PDF Email Distribution of Tableau Views Using PowerShell and Tabcmd

Data

Automated PDF Email Distribution of Tableau Views Using PowerShell and Tabcmd

by Tanner Ladd
//

I’m three months in to my career at InterWorks and think it’s high time for my first blog post. In this post, we’ll cover the basics of using PowerShell and Tabcmd to distribute PDF files of your Tableau views via email. I have to give the credit for this script to a former colleague whom, unfortunately, left InterWorks for Twitter. Thanks #DanielSeisun!

What You’ll Need

PDF distribution is a very common client request and I find myself recycling this code quite often. There are three files needed to make the magic happen. A PowerShell (PS1) script, an XML file containing configuration settings and a CSV file that holds URL filter criteria and the email addresses needed for distribution.

You will need to have both PowerShell and Tabcmd installed on the machine that will be running the script.

You can find instructions for PowerShell here: http://technet.microsoft.com/en-us/library/hh847837.aspx.

Tabcmd install instructions can be found here: http://kb.tableausoftware.com/articles/knowledgebase/installing-tabcmd.

Begin with the CSV File

Let’s start with the CSV file that contains our filter criteria and email addresses. In this case, I’ll use Rep_ID. I prefer to use integer fields for URL filters if possible. We could use a string field such as Rep_Name, but that requires a thorough scrubbing of spaces and special characters before it can be passed to the URL.

CSV File

Set Up the Config.xml File

Next we need to set up our config.xml file that holds variables for the PS1 script. A well commented sample config.xml file is attached to this page. Just follow the comments in the sample file and replace the items with your configuration specs.

Start Scripting

Finally, it’s time for some scripting! Make sure to set your PowerShell execution policy to ‘Remote Signed.’

Instructions for that can be found here: http://technet.microsoft.com/en-us/library/ee176949.aspx  

You will need to change a few variables in the script to match the config.xml file.

At this point, I should repeat that this post covers the basics only. I use Windows Task Manager to manage the run schedule for the production process. I also highly recommend encrypting sensitive info in the config.xml file such as passwords and smtp server addresses prior to putting this method into production.

Hop over to my good friend, Tim Rymer’s page for some encryption know how: http://www.interworks.com/blogs/trhymer/2013/07/08/powershell-how-encrypt-and-store-credentials-securely-use-automation-script 

The list.csv file may also need to be managed dynamically for those of you that have a large number of email recipients. I’ll cover my method of dynamically managing a large list.csv file in a future post. Hopefully the code is commented well enough for you to understand what is happening, but please don’t hesitate to contact me if you need assistance.

More About the Author

Tanner Ladd

Analytics Consultant
In 5 Schritten zu Mehrfachauswahl-Parametern Die Mehrfachauswahl der Parametersteuerung ist ein Feature, das viele Tableau-Enthusiasten liebend gern nutzen würden. Während diese ...
5 Steps to Enabling a Multi-Select Parameter Control in Tableau The multi-select parameter control is a feature many that Tableau enthusiasts would love to take advantage of. While the multi-select ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!