Using tabcmd in Command Prompt to edit Tableau Server

by Harry Osborne

Tableau Server is most often accessed and modified through the browser, as it can be reached through the username/password portal, and is user-friendly when navigating. However, one core concept of Server which is easier to build outside of the browser is automating processes; these can range from dynamic refresh times, downlading workbooks as PDFs (DISCLAIMER: I do not condone this behaviour), and even adding new users to the Server itself.

In this blog post, I will show you the basic route to access your Tableau Server through a Windows computer's Command Prompt (also known as Terminal on Macs), and how from here, you can remotely carry out processes without conventionally "stepping foot" within your Server. From there, I will demonstrate a few tasks possible inside Command Prompt, such as creating sites, creating projects and nesting projects, all with an England-Euro orientated theme.

The first step is actually in downloading the correct tabcmd from Tableau - not as easy a step as it may appear. Given that you are downloading this externally to your Server's initial installation, you need to verify that this is the same version of download as your Server. You can find that here on Tableau's website, and you want the ~100MB "TableauServerTabcmd.exe" download.

Next, you will want to do two different things: first, type "Command Prompt" into your Windows toolbar and select the application (this will open a daunting black box with a line or two of code-esque text), and you also want to navigate in your File Explorer to the download folder. This is most likely found in your computer's C: Drive, under Program Files --> Tableau --> Tableau Server, then head through until you reach the Command Line Utility file. Once you have opened this file, you will need to do one of two things: either click and highlight in the file path (the bar at the top of file explorer showing the pathway through your files) and type "cmd", or copy this pathway and paste it into your Command Prompt window.

Typing cmd in the file path will open a new window in Command Prompt, and tells the application that this is your location (i.e. located alongside Tableau's tabcmd); if you copy and paste this file path, hitting enter does the same function, just without opening a separate window.

An example of the file path

Now comes moving into the Command Prompt window itself. Whilst this might look quite scary, it does follow a (very) logical progression, and even comes with some global commands (i.e. commands you can use at any point) that can help you out. For example, "--help" displays helpful commands and general queries within the window. For a full list of the Tableau-compatible commands, look here for their documentation.

Command Prompt showing that it has recognised the file location

The first step was letting Command Prompt know your current location (which we did via the file path). The next is to actually connect with your Server through Command Prompt, using this string:

tabcmd --server "Servername" --username "Username"

This connects with the given Server, working off of the permissions of the username given. The "Servername" will be the http:// URL you get when searching for the site. It is worth noting here that I haven't included the command for password (even though I knew it would ask), and this was because Command Prompt will prompt you (get it?) to give this password anonymously once you hit enter. However, if you type "--password" along with the other commands, it will ask for your password, but will not hide it (and I didn't fancy publicising that today). Get this all right, and you should be in!

Initiating a successful Server connection

Next up, I'm going to show you how to create a site. These are typically the landing pages for Server, and allow division of information and data security across a singular Server. The syntax for this is fairly simple too:

  tabcmd createsite "Sitename" -r "SiteID"

Creating a site within an existing Server

Broken down, this command is to create a site that will display as, in my case, "England Euros 2020". However, this is rarely (if ever) the name you will reference if you need to use this site in other commands; instead, you would use the "-r" command (otherwise written as "--url"), which is where you specify a unique Site ID (I chose "itscominghome" for obvious reasons).

Here come the England references

Next up, we're going to create a project, and then a sub-project (a project within a project - "Project-ception", if you will). Projects are just Tableau's way of saying folders, so don't be put off by this slightly annoying naming system. This, again, works in a similar way to creating a site, but requires slightly more detail - not only are you specifying the name of the new project, but you must also then choose the site to put this folder in (I chose the same "England Euros 2020" site for consistency). Without choosing a site to land in, tabcmd will revert the command to the default site - in my case, this was a site called "Dump", not somewhere I wanted to be, nor deserving of my work. As such, the command for this was:

tabcmd createproject --name "Projectname" --description "Optionaldescription" -t "SiteID"

This (as seen in the image below) creates a project (I named mine after the soon-to-be-knighted saviour of English football, Raheem Sterling), with a description (an optional field I chose to include to test functions) and the SiteID specified.

Creating a project (folder) within my new site

This command again wanted me to input a password, as you are effectively logging out to log back in again to a separate site (as this site could not have existed when I started the session, because I made it. Yes it is confusing, no it does not get much simpler).

He shoots, he scores! (Ignore Harry Kane, he was a failed experiment...)

Now to make a sub-project. This is the most routine task, as you can omit specifying a site since you are looking for a project anyway, so this acts as a sort of anchor for the command when no site is present. This works as follows:

tabcmd createproject --parent-project-path "Parentproject"               --name "Subproject"

Command Prompt for a subproject creation

All that is really new here is the use of a "parent project path", a way of specifying the starting location for the subproject (i.e., the project). Just like that, Sterling's child is born!

Given his popularity on the Gilette ads, I felt young Sterling was deserving of his own subproject alongside dad, Raheem

Deleting is a similar undertaking, and all of the additional commands can be found under Tableau's documentation. I hope this helps with your tabcmd enquiries!

Although, obviously, you could just login and do it the simple way...