我一直在慢慢研究如何使用LogParser 2.2调用PowerShell脚本来转换IIS。我已经决定使用Azure Data Factory Batch Service Custom Activity来运行PowerShell脚本。我已经能够解决在Azure自定义批处理活动中运行PowerShell时出现的许多文件路径问题,但我不能解决这个问题。
目前我只是尝试通过写主机打印环境变量AZ_BATCH_APP_PACKAGE_powershellscripts#1.0,我已经能够打印其他环境变量了,但我相信这个变量末尾的#1.0引起了我所有的悲哀。顺便说一句,1.0是加载到Azure批处理框架中的应用程序版本。
以下所有尝试均已失败:
powershell powershell Write-Host "$AZ_BATCH_APP_PACKAGE_powershellscripts#1.0"
powershell Write-Host "$AZ_BATCH_APP_PACKAGE_powershellscripts#1.0"
powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts#1.0"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts\#1.0"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts/#1.0"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts`#1.0"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts`#1`.0"
powershell powershell Write-Host "$env:AZ_BATCH_APP_PACKAGE_powershellscripts\`#1.0"
powershell powershell Write-Host "$AZ_BATCH_APP_PACKAGE_powershellscripts`#1.0"这些工作,但要么是cmd窗口,要么不是我想要的变量:
powershell powershell Write-Host "$env:AZ_BATCH_TASK_DIR"
powershell powershell Write-Host "$env:AZ_BATCH_ACCOUNT_URL"
cmd /c echo %AZ_BATCH_APP_PACKAGE_powershellscripts#1.0%那么,让它在Azure中工作的秘密语法糖是什么?
发布于 2019-11-01 22:20:29
我经历了近50次尝试,才让它像这样工作:
powershell powershell Write-Host (Get-ChildItem Env:AZ_BATCH_TASK_DIR).Value
powershell powershell Write-Host (Get-ChildItem Env:AZ_BATCH_APP_PACKAGE_powershellscripts#1.0).Value现在,这只是运行存储在Azure批处理模块的附加应用程序中的PowerShell脚本的垫脚石。我希望微软会在Azure Data Factory中添加一个Databrick或更好的方法来运行PowerShell脚本,但在那之前,这是我发现的唯一运行powershell脚本的方法:
powershell powershell -command ("(Get-ChildItem Env:AZ_BATCH_APP_PACKAGE_powershellscripts#1.0).Value" + '\Powershell\processWebLogsFromAzure.ps1')这对于试图从Batch Task Dir运行的任何人来说都应该是有效的:
powershell powershell -command ("$env:AZ_BATCH_TASK_DIR" + '\wd\processWebLogsFromAzure.ps1')希望它能帮助一些人!
发布于 2019-10-31 02:09:20
当然,你可以这样做:
powershell powershell Write-Host "$((Get-Variable -Name 'AZ_BATCH_APP_PACKAGE_powershellscripts#1.0').Value)"或者这样:
powershell powershell Write-Host (Get-Variable -Name "AZ_BATCH_APP_PACKAGE_powershellscripts#1.0").Valuehttps://stackoverflow.com/questions/58631018
复制相似问题