> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuworkflowactivity.md).

# New-PSUWorkflowActivity

## SYNOPSIS

Creates a workflow activity definition.

## SYNTAX

```
New-PSUWorkflowActivity [-Type] <String> [-Name <String>] [-ScriptFullPath <String>] [-Parameters <Hashtable>]
 [-Expressions <Hashtable>] [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]
```

## DESCRIPTION

Builds a workflow activity definition that can be embedded in the `-Definition` script block of `New-PSUWorkflow`. The activity type controls which properties are available. For built-in and script-backed activities, the cmdlet can surface dynamic parameters based on the selected `-Type` and optional `-ScriptFullPath`. Use `-Parameters` to pass literal property values and `-Expressions` to assign PowerShell expressions when a property should be evaluated at runtime instead of serialized as a fixed value.

## EXAMPLES

### Example 1

```powershell
PS C:\> New-PSUWorkflowActivity -Type Flowchart
```

Creates a simple flowchart activity definition that can be used as the root activity of a workflow.

### Example 2

```powershell
PS C:\> New-PSUWorkflowActivity -Type Script -ScriptFullPath 'C:\ProgramData\UniversalAutomation\Repository\scripts\Deploy.ps1' -Name 'Deploy' -FailOnScriptError $true -DeconstructHashtableOutput $true
```

Creates a script activity and binds dynamic parameters from the script-backed workflow activity metadata.

### Example 3

```powershell
PS C:\> New-PSUWorkflowActivity -Type Sequence -Parameters @{ Activities = @(
>>     New-PSUWorkflowActivity -Type Flowchart
>> ) }
```

Creates a container activity and supplies nested activities through the `-Parameters` hashtable.

## PARAMETERS

### -AppToken

Specifies the app token to use when authenticating to the PowerShell Universal management API.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ComputerName

Specifies the URL or host name of the target PowerShell Universal instance. Bare host names are normalized to an `http://<host>:5000` URL.

```yaml
Type: String
Parameter Sets: (All)
Aliases: Uri

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Cookies

Reuses and persists authentication cookies for the current PowerShell session.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Credential

Specifies the credentials to use for Basic authentication against the PowerShell Universal management API.

```yaml
Type: PSCredential
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Expressions

Specifies activity property values as PowerShell expressions. Use this hashtable when the target activity property should execute an expression at runtime instead of storing a serialized literal value.

```yaml
Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Integrated

Uses the in-process integrated management client when the cmdlet runs inside PowerShell Universal.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Name

Specifies the activity name to assign to the generated workflow activity definition.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Parameters

Specifies literal activity property values. Each key must match a valid property for the selected activity type.

```yaml
Type: Hashtable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ScriptFullPath

Specifies the full path of the script when `-Type Script` is used. The cmdlet uses this path to resolve script-backed activity metadata and dynamic parameters.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -TrustCertificate

Allows connections to servers with untrusted TLS certificates.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Type

Specifies the workflow activity type to create, such as `Flowchart`, `Sequence`, or `Script`. The selected type determines which dynamic parameters and properties are available.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 0
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -UseDefaultCredentials

Uses the current Windows credentials when authenticating to the management API.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable, and -ProgressAction. For more information, see [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUTS

### None

## OUTPUTS

### PowerShellUniversal.Models.Workflows.WorkflowActivityDefinition

## NOTES

## RELATED LINKS

[New-PSUWorkflow](/powershell-universal/powershell-commands/new-psuworkflow.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuworkflowactivity.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
