I want to create a task which calls a Powershell script to do some processing. However I can't access Azure Batch runtime environment variables from my Powershell script.
I can access via cmd, command below correctly outputs
D:\batch\tasks\applications\test12020-05-04-17-32':
cmd /c echo %AZ_BATCH_APP_PACKAGE_Test#1%
However equivalent Powershell command below shows incorrect output
%AZ_BATCH_APP_PACKAGE_Test#1%':
powershell -Command echo %AZ_BATCH_APP_PACKAGE_Test#1%
Of course there is a hacky way around this which is to create a .bat script to call my .ps1 script. But I was looking for a better solution.
Is it possible to access Azure Batch runtime environment variables from Powershell?


exhois not really a PowerShell command, try:powershell -Command $Env:AZ_BATCH_APP_PACKAGE_Test#1? - iRoniRonimplied, you are using%name%in powershell ... and that will not work for accessing environment variables. you should use$env:Nameinstead. - Lee_Dailey