# Parameters

## Parameters

Jobs support automatically generating forms with parameters based on your script's `param` block. The type of control will change based on the type you define in the block. Parameters that are mandatory will also be required by the UI.

### Basic Parameters

Parameters can be simply defined without any type of parameter attribute and they will show up as text boxes in the UI.

```
param($Test)

$Test
```

![](/files/-MB4DnzruHtWQR7pMEZo)

### Type Parameters

UA supports various types of parameters. You can use String, String\[], Int, DateTime, Boolean, Switch and Enum types.

#### String

You can define string parameters by specifying the `[String]` type of by not specifying a type at all. Strings will generate a textbox.

```
param(
    [String]$Textbox,
    $Textbox2
)
```

![](/files/-MMY57K6W1Wgq-QP9Efn)

#### String Arrays

You can specify string arrays by using the `[String[]]` type specifier. String arrays will generate a multi-tag select box.

```
param([String[]]$Array)
```

![](/files/-MMY5SjN481NALNb2asK)

#### Date and Time

You can use the `[DateTime]` type specifier to create a date and time selector.

```
param([DateTime]$DateTime)
```

![](/files/-MMY5eVdKyXqt40NXEVW)

#### Boolean

You can use a `[Bool]` type selector to create a switch.

```
param([Bool]$Switch)
```

![](/files/-MMY5tuZIQ2V_Va_YTJa)

#### Integer

You can define a number selector by using the `[Int]` type specifier.

```
param([Int]$Number)
```

![](/files/-MMY7rhDbg3RqJGZZvWF)

#### Switch Parameter

You can define a switch parameter using the `[Switch]` type specifier to create a switch.

```
param([Switch]$Switch)
```

![](/files/-MMY67wc08eQuJt-h-iL)

#### Enumerations

You can use System.Enum values to create select boxes. For example, you could use the `System.DayOrWeek` to create a day of the week selection box.

```
param([System.DayOfWeek]$DayOfWeek)
```

![](/files/-MMY6LxdVRIJkC7d4yPW)

### Help Messages

You can define help messages for your parameters by using the `HelpMessage` property of the `Parameter` attribute.

```
param(
    [Parameter(HelpMessage = "Class you want to enroll in")]
    [string]$Class
)
```

![](/files/-MMY76SHgqRfPK0RCdlQ)

### Required Parameters

You can use the Parameter attribute to define required parameters.

```
param(
    [Parameter(Mandatory)]
    $RequiredParameter
)

$RequiredParameter
```

![](/files/-MB4E28hil_DldKDhYy-)

## Passing Parameters from PowerShell

You can pass parameters from PowerShell using the `Invoke-UAJob` cmdlet. This cmdlet supports dynamic parameters. If you have a `param` block on your script, these parameters will automatically be added to `Invoke-UAJob`.

For example, I had a script named Script1.ps1 and the contents were are follows.

```
param($MyParameter)

$MyParameter
```

I could then invoke that script using this syntax.

```
Invoke-UAScript -Name 'Script.ps1' -MyParameter "Hello"
```

The result would be that Hello was output in the job log and pipeline.


---

# Agent Instructions: 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:

```
GET https://docs.powershelluniversal.com/v1/automation/scripts/parameters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
