I am trying to run a PowerShell script from within an Azure, Data Factory, Batch Service, Custom Activity. The closest I've gotten to this working is the following:
powershell powershell -command '$env:AZ_BATCH_TASK_DIR\wd\processInAzure.ps1'
When I run this I get the following error message
At line:1 char:23
+ $env:AZ_BATCH_TASK_DIR\wd\processInAzure.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected token '\wd\processInAzure.ps1' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
I've been able to get a directory listing of $env:AZ_BATCH_TASK_DIR\wd and see that processInAzure.ps1 exists at this location. I've been able to Write-Host "Hello from Azure" so I can see powershell is working. What I'm not getting is how to reference the ps1 script file using an environment variable. Would anyone know the syntax sugar to get this working?
With Architect Jamie's input (including his deleted edit!!! Put edit back it directly led to the solution) I was able to put a few things together to get this to work. The double powershell at the beginning of the command line is not a typo BTW. This is what ended up working:
powershell powershell -command ("$env:AZ_BATCH_TASK_DIR" + '\wd\processInAzure.ps1')
What didn't work is the following:
powershell powershell -command ("$env:AZ_BATCH_TASK_DIR" + "\wd\processInAzure.ps1")
powershell powershell -command ("$env:AZ_BATCH_TASK_DIR\wd\processInAzure.ps1")
powershell -command ("$env:AZ_BATCH_TASK_DIR" + '\wd\processInAzure.ps1')