Quantcast
Channel: InterWorks
Viewing all articles
Browse latest Browse all 2697

Leverage PowerShell and Tableau to Extract Server Datasources

$
0
0

Question:

Of all the workbooks on Tableau Server, which (1) use a Tableau Server data source and (2) what workbook(s) use them?

Answer:

Since there’s no simple and straightforward way to extract this information from the default views on Tableau Server (_datasources, etc.), we’ll use a short and sweet PowerShell script to do the heavy lifting for us.

Since each Tableau workbook contains all the information about connections, calculations, etc., we’ll use our script to run through each of them and extract the information we need.

Step 1:
Pull down the attached PowerShell script and update the $input_path and $output_file variables to your specific requirements (where are your Tableau workbooks and where do you want the results to go, respectively). Save this file as a ‘.ps1’ file and save to the desired path.

Step 2:
Open Windows PowerShell (Windows + R) and type “powershell”.  Navigate to the directory where you saved the file from Step 1.

powershell

Step 3:
Run the script by typing: ‘ .\{your file name}.ps1 ‘ Note: You may have to make sure you are able to execute these scripts. Check here: http://technet.microsoft.com/en-us/library/ee176949.aspx

$input_path = ‘c:\Users\mroberts\Documents\My Tableau Repository\Workbooks\*.twb’
  $output_file = ‘c:\users\mroberts\data.csv’
  $regex = ‘(?<=class=)(.*)(?=directory=)’
  $output= [System.Windows.Forms.MessageBox]::Show("Extract Data Sources?" , "Status" , 4)
  if ($output -eq "YES")
  {
  select-string -Path $input_path -Pattern $regex -AllMatches | select-object -Property Filename, @{Name="Datasource_Name";Expression = {$_.Matches}} | Export-Csv $output_file -NoTypeInformation -Delimiter ";" 
  }
  else 
  {
  write-host "okay...bye"
  }

Step 4:
You now have a listing of all your workbooks that use a Tableau Server data source.


Viewing all articles
Browse latest Browse all 2697

Trending Articles