dev3lopcom, llc, official logo 12/8/2022

Connect Now

Tableau Server Automated Dashboard Image or Images

Tableau Server Automated Dashboard Image or Images

We show you How to do Tableau Server Automated Dashboard Image or Images using Tab admin. While offering Tableau Services, you’re bound to create a few tabcmd solutions!

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

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

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 the Tableau Server. However, its installer is not included. Download the installer from the Tableau website if you want to run it on a computer other than the initial server node. 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; there are no complaints yet.

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

Tableau Server automation is helpful.

Are you ready to automate pulling PNG from the Tableau Server? This is your helpful guide.

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 the Tableau Servers repo.

It’s enjoyable to pick up a new language if you have the time or like new puzzles; we will use PowerShell.

Automate Dashboard Image or PNG Export Script

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

The code is pasted into a .txt and saved 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, so be advised. However, this has been seen by thousands and used hundreds of times daily by 30+ clients. Ping

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

We hope this helps you 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
# PNG EXPORT Script
# 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
{
[CmdletBinding()]
param (
[string]$connectionString,
[string]$query
)
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
$adapter.Fill($dataset)
$dataset.Tables[0]
}
#¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
# |
# 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 = @”
SELECT
v.view_url
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; you can 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) )
{
Try
{
$newwb = $wb -replace “/”, “_”
tabcmd export $wb –png -f $newwb 2>> C:\POSH\PNGExport\TabCmdGetWbErr.txt
}
Catch
{
Write-Error -Message “Error occurred: $_”
}
}
#_________________________________
# 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

As we said, Tableau server automated dashboard images are straightforward with the correct code & explained in detail!

Let us know if you run into issues.