我正在尝试在批处理 StartTask 中运行 powershell 脚本,但遇到了错误。以下是我在创建池 startTask 时出错的代码:
def create_pool(batch_service_client, pool_id, resource_files, node_os_family):
print('Creating pool [{}]...'.format(pool_id))
task_commands = [
'copy $AZ_BATCH_TASK_WORKING_DIR/python_tutorial_task.py $AZ_BATCH_NODE_SHARED_DIR',
'powershell.exe -command set-executionpolicy remotesigned',
"powershell.exe -command $AZ_BATCH_NODE_STARTUP_DIR" + "\\" + "PrepPython.ps1",
'pip install azure-batch',
'pip install azure-storage',
'pip install cryptography']
... ...
后来我把这些命令打包成一行,前面附加了“cmd.exe /c”。但这不起作用,并不断引发以下错误:
At line:1 char:27
+ $AZ_BATCH_NODE_STARTUP_DIR\PrepPython.ps1
+ ~~~~~~~~~~~~~~~
Unexpected token '\PrepPython.ps1' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : UnexpectedToken
... ...
有人对此有想法吗?