PowerShellOnTargetMachines@1 - 目标计算机上的 PowerShell v1 任务
使用此任务在远程计算机上执行 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
. 必需。
指定 PowerShell 脚本在目标计算机或 UNC 路径上的位置,例如 C:\BudgetIT\Web\Deploy\Website.ps1
。
ScriptArguments
-
脚本参数
string
.
指定 PowerShell 脚本的参数。 可以是序号或命名参数,如 -testParam
test。
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
)。 如果指定了多个标记,则任务将在具有指定标记的所有计算机中运行。 默认在所有计算机中运行任务。
任务控制选项
除了任务输入,所有任务都有控制选项。 有关详细信息,请参阅 控制选项和常见任务属性。
输出变量
无。