activities
latest
false
重要 :
请注意,此内容已使用机器翻译进行了部分本地化。 新发布内容的本地化可能需要 1-2 周的时间才能完成。
UiPath logo, featuring letters U and I in white

工作流活动

上次更新日期 2026年2月25日

调用 PowerShell

UiPath.Core.Activities.InvokePowerShell

描述

“调用 Power Shell”活动使用指定的输入参数执行 PowerShell 命令或脚本。

备注:

限制 PowerShell 访问的防病毒策略可能会阻止使用 PowerShell 相关活动。例如,在迈克菲端点安全中启用规则 ID 6151 时,您不能使用“调用工作流文件”和“调用 Power Shell”。

项目兼容性

Windows - Legacy | Windows

配置

  • 命令文本 - 要执行的 PowerShell 命令。此值可以是 cmdlet 的名称,也可以是 PowerShell 脚本的文本。

属性面板

常见
  • ContinueOnError - Specifies if the automation should continue even when the activity throws an error. This field only supports Boolean values (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.
    备注:

    如果“Try Catch 异常处理”中包含该活动且“出错时继续”属性的值为“True”,则系统在执行项目时不会捕获任何错误。

  • “显示名称”- 活动的显示名称。
输入
  • 参数 - PowerShell 命令参数字典。可以使用特定命令 (cmdlet) 或脚本。
    • 特定命令:调用特定命令时,参数名称应与命令参数的名称相符。

例如,如果您使用 Get-Command -Module CimCmdlets 作为输入,则输入值必须为 Get-Command,并且应将参数命名为 Module,并将值设置为 "CimCmdlets"

  • 脚本:在脚本开头,您需要指定参数的类型。(可选)您也可以强制使用参数,以强制脚本始终使用调用者设置的参数进行调用。

例如,以下脚本支持使用两个参数, 其中一个参数类型为字符串,另一个参数类型为整数:

Param(
  [Parameter(Mandatory=$true)]
  [string]$Name,
  [int]$Age
)
Param(
  [Parameter(Mandatory=$true)]
  [string]$Name,
  [int]$Age
)

然后,通过在参数名称前面添加 $,即可在脚本中引用这些参数。

  • 输入- PSObject 的集合,系统会将其传递至用于执行命令的管道编写器。可以是另一个“调用 PowerShell” 活动的输出。您可以使用$input在脚本中引用管道输入。
    备注:

    此变量由 PowerShell 隐式创建。定义名为input变量或参数可能会生成错误或导致冲突。建议为管道保留input一词。

其他
  • 执行模式 - 选择要用于执行所提供命令或脚本的 PowerShell 版本。这仅适用于 Windows 项目,Windows 旧版项目目标 Windows PowerShell 5.1(32 位)版本。 可选择以下选项:
    • PowerShell 7.2(64 位) - 使用基于.NET6 PowerShell Core Shell。在此版本中,PowerShell 托管在 .NET 6 Runtime 中。使用的任何数据都可以通过该活动直接访问,并且可以导入到工作流中。
    • PowerShell 5.1(64 位) - 使用 64 位 Windows PowerShell 可执行文件。在此版本中,PowerShell 与 Windows 捆绑在一起,默认情况下位于C:\Windows\System32\WindowsPowerShell\v1.0\中。在此执行模式下,PowerShell 使用预装的 Shell 在计算机本地远程运行。.NET Remoting 引入了在不同 .NET 运行时之间序列化和反序列化信息的需求,因此无法重建的对象包含在PSObjectPSCustomObject中。
    • PowerShell 5.1(32 位) - 使用 32 位 Windows PowerShell 可执行文件。在此版本中,PowerShell 与 Windows 捆绑在一起,默认情况下位于C:\Windows\SysWOW64\WindowsPowerShell\v1.0\或 )。在此执行模式下,PowerShell 使用预装的 Shell 在计算机本地远程运行。.NET Remoting 引入了在不同 .NET 运行时之间序列化和反序列化信息的需求,因为无法重建的此类对象包含在PSObjectPSCustomObject中。PSObjectPSCustomObjects保存有关原始对象整体结构的信息,可用于手动重建对象。
  • 是脚本 - 指定命令文本是脚本还是直接命令。管道、变量和参数可与单个命令或脚本一起使用。
  • PowerShell 变量- 命名对象字典,表示在“调用 PowerShell”活动的当前会话中使用的变量。PowerShell 命令或脚本可以从InIn/Out变量中检索信息,并可以设置Out变量。要在脚本中引用变量,请使用变量标识符字符$来表示其后的文本是变量名称。示例: $firstVariable
    备注:

    变量名称不区分大小写。

  • “私有”- 选中后将不再以“Verbose”级别记录变量和参数的值。
  • “类型参数”- 设置输出变量的类型。
输出
  • “输出”- 执行命令后返回的“类型参数”对象的集合。可用于传送多个“调用 PowerShell”活动。
  • 描述
  • 项目兼容性
  • 配置
  • 属性面板

此页面有帮助吗?

获取您需要的帮助
了解 RPA - 自动化课程
UiPath Community 论坛
Uipath Logo
信任与安全
© 2005-2026 UiPath。保留所有权利。