Reputation: 43
I am having issues converting a bat command to my Powershell script. I am trying to run TabCMD (Tableau Command) in my PS script.
The below bat file works: tabCMD.bat
cd C:\Program Files\Tableau\Tableau 9.0\bin
tableau refreshextract --server "https://online.tableausoftware.com" --username "[email protected]" --password "password" --site "gameMetrics" --project "acquisition" --datasource "VisExtract"
I want to translate this into a Powershell script: PSTabCMD.ps1
$server='https://online.tableausoftware.com'
$username='[email protected]'
$password='password'
$site='gameMetrics'
$project='acquisition'
$datasource='VisExtract'
Set-Location "C:\Program Files\Tableau\Tableau 9.0\bin"
$TabCMD = "tableau refreshextract --server $server --username $username --password $password --site $site --project $project --datasource $datasource"
Invoke-Expression -Command:$TabCMD
write-host 'Command complete!!'
I get the below error:
'tableau : The term 'tableau' is not recognized as the name of a cmdlet, function, script file, or operable program.'
I've also tried changing the Invoke-Expression to & "$TabCMD" and start-process $TabCMD but those don't work either.
I need to update several extracts and don't want to call a bunch of bat files.
Does anyone know how to run this TabCMD command within Powershell?
Thanks!
Upvotes: 0
Views: 3633
Reputation: 18176
Change tableau
to .\tableau
and it will probably work. PowerShell doesn't let you run things in the current directory without explicitly referencing the current directory.
Upvotes: 3