---
sourceDocument: Australia ServiceNow AI Platform Capabilities
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/servicenow-platform

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia ServiceNow AI Platform Capabilities

ft:clusterId :

    - platcap

bundleId :

    - platcap

workflow :

    - Platform


---

# PowerShell activities

# PowerShell activities {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 Minuten Lesedauer

PowerShell is built on the Windows .NET Framework and is designed to control and automate the administration of Windows machines and
applications.

PowerShell must be installed on any MID Server that uses these activities. MID Servers using
PowerShell must be installed on a supported Windows operating system. ServiceNow supports PowerShell 3.0 to 5.1.{#c_OrchestrPowerShellActivities__ph_Supported_PowerShell_Versions}

The ServiceNow
[Orchestration](https://servicenow-prod.fluidtopics.net/WOhjVil_WOmFwJ8_V92d6g "Use Orchestration activities in a Workflow to integrate with third-party systems.") plugin
adds these basic PowerShell activities to workflows. For instructions on using activities from
the PowerShell activity pack, see [PowerShell activity pack](https://servicenow-prod.fluidtopics.net/kLiHXAZ_lDvX_V0sHYEVrQ "PowerShell is built on the Windows .NET Framework and is designed to control and automate the administration of Windows machines and applications.")

## Legacy Run PowerShell activity {#ariaid-title2}

The Run PowerShell activity executes Windows PowerShell commands on a MID
Server.
Wichtig:  
This activity is deprecated and is unavailable for new workflows. To replace the functionality of this activity, use the [Powershell activity template](https://servicenow-prod.fluidtopics.net/SV5g3MJvrMeLhWdD7UG1VQ#t_CreateAPowershellActivity "Create a custom PowerShell activity return data to a workflow from a host using Microsoft PowerShell.") to create a custom, scoped activity. Workflows from a previous release that use the Run PowerShell activity can continue to do so.

### Result Values

The workflow designer can assign a result value using activity.result from within a script field of the activity. By default, the success or failure of the PowerShell commands used determines the result value of the Run PowerShell activity. Possible result values are:

* Success
* Failure
{#r_RunPowershellActivity__ul_oqc_yxs_hp}

### Scratchpad Entries

Information written to <var class="keyword varname">stdout</var> by the executing script is captured and
returned to the activity in the<var class="keyword varname"> activity.output</var> variable. This
information can be parsed, processed, or saved (to a scratchpad variable, for example) for
future processing in the activity's sensor script.  
An example would be to run the get-date command to get the MID Server's current time. This sensor script saves the full output received, but we can process it to return and save only the time.Abbildung : 1. PowerShell activity  
Hinweis:  
This is an over-simplified example. In most cases, the script operates against some remote Windows computer. However, the principal is the same -- whatever is written to `stdout` is returned in `activity.output` and available to process.

### Input Variables

{#r_RunPowershellActivity__table_kh2_mys_hp__entry__2}

| Field | Description |
|-|-|
| Hostname | IP address of the target Windows machine. This value is mapped to the <var class="keyword varname">$computer</var> variable for use in commands (see the example in the Command field). A PowerShell credential variable called <var class="keyword varname">$cred</var> that is based on information in the ServiceNow Credentials table will authenticate on the computer pointed to by Hostname. |
| Command | Enter the PowerShell command to run. For example, to execute a simple WMI query against a remote machine pointed to by the <var class="keyword varname">hostname</var> variable, the command is: get-wmiobject <class> -computer $computer -credential $cred If no credentials authenticate on the computer, the command runs in the context of the MID Server user. You cannot run both a command and a script file. Specifying a command hides the <var class="keyword varname">Script file</var> variable. |
| Sensor script | The script to run using the results of the probe. The output from the probe is contained in a variable called <var class="keyword varname">output</var>. Any error from the probe is contained in a variable called <var class="keyword varname">error</var>. |
| Script file | The [Enable script file synchronization for Windows enhanced security](https://servicenow-prod.fluidtopics.net/vu1Hjk_D3VmPooctXzxerQ#c_EnableScriptFileSyncWinESecure "Windows Internet Explorer enhanced security blocks downloaded files that it determines are potentially dangerous."). You cannot run both a script file and a command. Selecting a script file hides the <var class="keyword varname">Command</var> variable. |
| PowerShell script variables | Additional parameters, in JSON format, used by the specified script file. |
[Tabelle : 1. Input Variables]

{#r_RunPowershellActivity__table_kh2_mys_hp}

### States

The activity state tells the workflow engine what to do with the activity.{#r_RunPowershellActivity__table_zvx_mzs_hp__entry__2}

| State | Description |
|-|-|
| Executing | The workflow engine knows to start the onExecute function of the activity. |
| Finished | The activity finished running. See the result value for the outcome of the activity. |
| Cancelled | This activity, or the workflow that contains this activty, was cancelled. |
[Tabelle : 2. States]

{#r_RunPowershellActivity__table_zvx_mzs_hp}  
Add workflow variables for the command line using the normal workflow variable syntax. In the example above, if the \<class\> was in a workflow input variable called <var class="keyword varname">myclass</var>, the command would look like:

    get-wmiobject $ {workflow. inputs. myclass } -computer $computer --credential $cred
    Similarly  if the variable  is a scratchpad variable named myclass , the command would look like :
    get -wmiobject $ {workflow. scratchpad. myclass } -computer $computer --credential $cred

## HResult codes {#ariaid-title3}

When a PowerShell script encounters an error, the Windows machine may return an HResult
code as part of the error message.

PowerShell activities can read and interpret this code. Not all PowerShell errors include an
HResult code. In the event of a failed PowerShell script, you can use the HResult code to move
the workflow through a specific condition.

For example, when resetting an Active Directory password to a password that does not meet
policy requirements, such as minimum length or complexity, the PowerShell script returns the
HResult code -2146022651. To use this code, create an activity condition with the
Condition value of <var class="keyword varname">activity.hresult = -2146022651</var>. If
the PowerShell script returns this code when the activity runs, the workflow transitions through
this new condition.

