We show you How to do Tableau Server Automated Dashboard Image or Images using Tab admin. Tabcmd

While working at tableau.com, our founder started using powershell to bulk automate dashboard content, and focused on iterating things from tabcmd, due to the simplicity.

You are able to begin by using spreadsheets and the tableau repo as a data source. This is easy to change into something more robust as you scale this tableau server automation solution across your sites, projects, or everything at once.

Tableau provides the tabcmd command-line utility which you can use to automate site administration tasks on your Tableau Server site. For example, creating or deleting users, projects, and groups.

Note: The tabcmd utility is included with Tableau Server, however its installer is not included. If you want to run it on a computer other than the initial server node, you need to download the installer from the Tableau website. For more information, see Install tabcmd.

keyboard and mouse used to automate dashboard images off of tableau server

Thanks for visiting our Tableau Server Image Automation blog.

There are many ways to solve this workload; this is one version of the solution, likely legacy since recent updates, we will find out as the application grows, no complaints yet.

This particular chunk of code is “user-friendly” enough for non-technical experts to automate images off of tableau server. We start by explaining what this is, how it works, and leave comments in the code.

Tableau Server automation is helpful.

It’s possible to use it to maintain an automated process… Which means, hands free automation.

It’s a 100% successful script to automate content, since 2015.

Don’t stress out your hands, manual clicking is not a strategy.

hands hitting desk with coffee and keyboard because manually trying to get images off of tableau server is time consuming

Keep your hands and arms relaxed. The code will help you automate the process using Tableau Servers repo.

It’s enjoyable to pick up a new language if you have the time or like new puzzles, we are going to use powershell.

Automate Dashboard Image or PNG Export Script

Please, Note that in PowerShell the hashtag is a comment, and the script will not see this. You paste the code to win.

The code is pasted into a .txt and save it as a .ps1, save and close after you add your edits and environment variables. 

We can’t offer you a .ps1 file because that would not work as a download, .ps1 files can have funky stuff in it, so be advised. However, this has been seen by thousands and used hundreds of times a day by 30+ clients. Ping

Update: I will come and upgrade the code to explain each segment.

We hope this helps your overcome the hard request! Scraping images or whatever you need for automated tableau server content can be accomplished with this code below. Have fun!

#Comment – Read Comments, Edit Variables, Run it!

.#_______________________________Start here
# A powershell script to pull down pngs of Tableau “views”
# Created By – Tyler Garrett
# Email – tyler@dev3lop.com
# Version 1
# || NOTES ||
# Create Directory C:\POSH\PNGExport
# This directory will store all content
# Script expects Tableau Bin directory to be set in Environment Variable Path

# Set variables
$TS = “http://localhost” #Server
$username = “admin” #tableau server account
$pass = “admin” #tableau server password
$pgUSR = “readonly” #readonly account password must be setup beforehand
$pgPW = “admin” #postgres password
$SiteF = “BeepTest” #site you’re pulling PNGs from
$ProjectF = “ProjectTest” #project you’re pulling PNGs from
cd C:\POSH\PNGExport
# |
# Query postgresql and build CSV with workbook URL (3 steps)|
# |
# |
# 1.Connection info |
# |

#Commented – Open connection to database to query repo

Set-Location “C:\POSH\PNGExport”
function Get-Stuff
param (
Write-Verbose ‘Getting Tableau Server Extract’
$connection = New-Object -TypeName System.Data.Odbc.OdbcConnection
$connection.ConnectionString = $connectionString
$command = $connection.CreateCommand()
$command.CommandText = $query
$adapter = New-Object System.Data.Odbc.OdbcDataAdapter $command
$dataset = New-Object -TypeName System.Data.DataSet
# |
# 2.Query PostgreSQL |
# |


#Commented Utilize Driver and funnel query to repo through.

$connectionString = ‘Driver={PostgreSQL ANSI(x64)};Server=localhost; Port=8060; Database=workgroup; Uid=’+$pgUSR+’; Pwd=’+$pgPW+’;’
$query = @”
FROM _views v
INNER JOIN _workbooks w on (w.id=v.workbook_id)
INNER JOIN _sites s on (s.id = v.site_id)
WHERE s.name = ‘$SiteF’
and w.project_name = ‘$ProjectF’
# | Don’t change anything in the syntax around the query above, I tried and it broke.
# 3.Build CSV to be used for tabcmd from the above query|
# |
Get-Stuff -connectionString $connectionString -query $query | `
Select-Object -Skip 1 -Property view_url | `
Export-Csv -Path “C:\POSH\PNGExport\Reports.csv” -NoTypeInformation -Delimiter “;”
# Loop through CSV from above and export those views as PNG files
# -replace is used in the loop to save the file name with out a “/”
# because this value isn’t allowed in a file naming convention
# error output will be generated in the folder


#Comment Loops in Powershell to export PNGs

#Comment; pay attention to this looping process and you will be able to tabcmd your way through anything.

#NOTE: Change Paths

tabcmd login -s $TS -u $username -p $pass -t $SiteF
ForEach ($wb in @(Import-Csv -Path C:\POSH\PNGExport\Reports.csv | select -expand view_url) )
$newwb = $wb -replace “/”, “_”
tabcmd export $wb –png -f $newwb 2>> C:\POSH\PNGExport\TabCmdGetWbErr.txt
Write-Error -Message “Error occured: $_”
# Convert PNG to BMP – helps people who are moving these photos into Powerpoint
# Comment the Dir *.png…. line out of the script if you want to keep them as PNG files
Dir *.png | rename-item -newname { $_.name -replace ‘\.png$’,’.bmp’ }
tabcmd logout
#_______________________________End here

End of your Tableau Server Automated Dashboard Image Script

Like we said, Tableau server automated dashboard images is very straight forward with the correct code & explained in detail!

Let us know if you run into issues.