AzurePowerShell@1 - Azure PowerShell v1 任务

使用此任务在 Azure 环境中运行 PowerShell 脚本。 Azure 上下文使用提供的 Azure 资源管理器 服务连接进行身份验证。

语法

# Azure PowerShell v1
# Run a PowerShell script within an Azure environment.
- task: AzurePowerShell@1
  inputs:
    #ConnectedServiceNameSelector: 'ConnectedServiceName' # 'ConnectedServiceName' | 'ConnectedServiceNameARM'. Azure Connection Type. Default: ConnectedServiceName.
    ConnectedServiceName: # string. Required when ConnectedServiceNameSelector = ConnectedServiceName. Azure Classic Subscription. 
    #ConnectedServiceNameARM: # string. Required when ConnectedServiceNameSelector = ConnectedServiceNameARM. Azure Subscription. 
    ScriptType: 'FilePath' # 'FilePath' | 'InlineScript'. Required. Script Type. Default: FilePath.
    #ScriptPath: # string. Optional. Use when ScriptType = FilePath. Script Path. 
    #Inline: # string. Optional. Use when ScriptType = InlineScript. Inline Script. 
    #ScriptArguments: # string. Script Arguments.

输入

ConnectedServiceNameSelector - Azure 连接类型
string. 允许的值: ConnectedServiceName (Azure 经典) 、 ConnectedServiceNameARM (Azure 资源管理器) 。 默认值:ConnectedServiceName


ConnectedServiceName - Azure 经典订阅
string. 当 ConnectedServiceNameSelector = ConnectedServiceName 时,需要此选项。

运行 PowerShell 之前要配置的 Azure 经典订阅。


ConnectedServiceNameARM - Azure 订阅
string. 当 ConnectedServiceNameSelector = ConnectedServiceNameARM 时,需要此选项。

运行 PowerShell 之前要配置的 Azure 资源管理器订阅。


ScriptType - 脚本类型
string. 必需。 允许的值: FilePath (脚本文件路径) , InlineScript (内联脚本) 。 默认值:FilePath

脚本的类型:文件路径或内联。


ScriptPath - 脚本路径
string. 可选。 在 时 ScriptType = FilePath使用 。

脚本的路径。 这应该是完全限定的路径或相对于默认工作目录的路径。


Inline - 内联脚本
string. 可选。 在 时 ScriptType = InlineScript使用 。 默认值:# You can write your azure powershell scripts inline here. \n# You can also pass predefined and custom variables to this script using arguments

指定要执行的脚本。 支持的最大内联脚本长度为 500 个字符。 如果要使用较长的脚本,请使用文件中的脚本。


ScriptArguments - 脚本参数
string.

要传递给 PowerShell 的其他参数。 这些参数可以是序号参数,也可以是命名参数。


任务控制选项

除了任务输入,所有任务都有控制选项。 有关详细信息,请参阅 控制选项和常见任务属性

输出变量

无。

要求

要求 说明
管道类型 YAML,经典内部版本,经典版本
运行平台 Agent、DeploymentGroup
需求 自承载代理必须具有满足以下要求的功能才能运行使用此任务的作业:azureps
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任意
可设置的变量 Any
代理版本 1.95.0 或更高版本
任务类别 部署