使用此任务在远程计算机上执行 PowerShell 脚本。
语法
# PowerShell on Target Machines v1
# Execute PowerShell scripts on remote machine(s).
- task: PowerShellOnTargetMachines@1
inputs:
EnvironmentName: # string. Required. Machines.
#AdminUserName: # string. Admin Login.
#AdminPassword: # string. Password.
#Protocol: # 'Http' | 'Https'. Protocol.
#TestCertificate: true # boolean. Optional. Use when Protocol = Https. Test Certificate. Default: true.
# Deployment
ScriptPath: # string. Required. PowerShell Script.
#ScriptArguments: # string. Script Arguments.
#InitializationScriptPath: # string. Initialization Script.
#SessionVariables: # string. Session Variables.
# Advanced Options
#RunPowershellInParallel: true # boolean. Run PowerShell in Parallel. Default: true.
#ResourceFilteringMethod: 'machineNames' # 'machineNames' | 'tags'. Select Machines By. Default: machineNames.
#MachineNames: # string. Filter Criteria.
输入
EnvironmentName
-
计算机
string
。 必填。
指定计算机 IP 地址或 FQDN 的逗号分隔列表以及端口。 默认端口基于所选协议。
例如:dbserver.fabrikam.com,dbserver_int.fabrikam.com:5986,192.168.12.34:5986
还可以提供其他任务的输出变量,例如 $(variableName)
。 如果使用 HTTPS,计算机的名称或 IP 应与证书中的 CN 匹配。
AdminUserName
-
管理员登录
string
。
指定目标计算机的管理员登录名。
AdminPassword
-
密码
string
。
指定目标计算机的管理员密码。 接受在生成/发布定义中定义的变量,$(passwordVariable)
。 可以将变量类型标记为 secret
来保护它。
Protocol
-
协议
string
。 允许的值:Http
、Https
。
指定要用于与计算机建立 WinRM 连接的协议。 默认值是 HTTPS
。
TestCertificate
-
测试证书
boolean
。 可选。 当 Protocol = Https
时使用。 默认值:true
。
跳过由受信任的证书颁发机构验证计算机证书的真实性。 WinRM HTTPS 协议需要此参数。
ScriptPath
-
PowerShell 脚本
string
。 必填。
指定目标计算机上或 UNC 路径上 PowerShell 脚本的位置,例如 C:\BudgetIT\Web\Deploy\Website.ps1
。
ScriptArguments
-
脚本参数
string
。
指定 PowerShell 脚本的参数。 可以是序号参数或命名参数,例如 -testParam
测试。
InitializationScriptPath
-
初始化脚本
string
。
指定目标计算机上的 DSC 数据脚本的位置或 UNC 路径(如 C:\BudgetIT\Web\Deploy\WebsiteConfiguration.ps1
)。
SessionVariables
-
会话变量
string
。
指定这两个脚本的通用会话变量。 例如,$variable = value
或 $var1 = "value, 123"
。
RunPowershellInParallel
-
并行运行 PowerShell
boolean
。 默认值:true
。
如果设置为 true
,则可在目标计算机上并行运行 PowerShell 脚本。
ResourceFilteringMethod
-
按 选择计算机
string
。 允许的值:machineNames
(计算机名称),tags
。 默认值:machineNames
。
可选。 通过提供计算机名称或标记指定计算机的子集。
MachineNames
-
筛选条件
string
。
此输入仅适用于计算机组或输出变量。 目前不支持平面计算机列表。
指定计算机列表,如 dbserver.fabrikam.com, webserver.fabrikam.com, 192.168.12.34
或标记,如 Role:DB; OS:Win8.1
。 如果指定了多个标记,则任务将在具有指定标记的所有计算机中运行。 默认值在所有计算机中运行任务。
任务控制选项
除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性。
输出变量
没有。