Skip to content

Commit a25c051

Browse files
committed
Refresh articles
1 parent a88e0bc commit a25c051

7 files changed

+113
-110
lines changed

articles/logic-apps/add-run-powershell-scripts.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: Add and run PowerShell in Standard workflows
2+
title: Add and Run PowerShell in Standard Workflows
33
description: Write and run PowerShell script code in Standard workflows to perform custom integration tasks using Inline Code operations in Azure Logic Apps.
44
ms.service: azure-logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, swghimire, shahparth, azla
77
ms.topic: how-to
8-
ms.date: 08/13/2024
8+
ms.date: 05/23/2025
99
# Customer intent: As a logic app workflow developer, I want to write and run PowerShell code so that I can perform custom integration tasks in Standard workflows for Azure Logic Apps.
1010
---
1111

@@ -23,11 +23,11 @@ This capability provides the following benefits:
2323

2424
- Write your own scripts within the workflow designer so you can solve complex integration challenges. No other service plans are necessary.
2525

26-
This benefit streamlines workflow development plus reduces the complexity and cost with managing more services.
26+
This benefit streamlines workflow development, and it reduces the complexity and cost with managing more services.
2727

2828
- Generate a dedicated code file, which provides a personalized scripting space within your workflow.
2929

30-
- Integrate with [Azure Functions PowerShell Functions](../azure-functions/functions-reference-powershell.md), which provides powerful functionality and inheritance for advanced task execution.
30+
- Integrate with [Azure Functions PowerShell functions](../azure-functions/functions-reference-powershell.md), which provides powerful functionality and inheritance for advanced task execution.
3131

3232
- Deploy scripts alongside your workflows.
3333

@@ -39,13 +39,13 @@ This guide shows how to add the action in your workflow and add the PowerShell c
3939

4040
* The Standard logic app workflow where you want to add your PowerShell script. The workflow must already start with a trigger. For more information, see [Create example Standard logic app workflows](create-single-tenant-workflows-azure-portal.md).
4141

42-
You can use any trigger for your scenario, but as an example, this guide uses the **Request** trigger named **When a HTTP request is received** and also the **Response** action. The workflow runs when another application or workflow sends a request to the trigger's endpoint URL. The sample script returns the results from code execution as output that you can use in subsequent actions.
42+
You can use any trigger for your scenario, but as an example, this guide uses the Request trigger named **When a HTTP request is received** and also the **Response** action. The workflow runs when another application or workflow sends a request to the trigger's endpoint URL. The sample script returns the results from code execution as output that you can use in subsequent actions.
4343

4444
## Considerations
4545

46-
- The Azure portal saves your script as a PowerShell script file (.ps1) in the same folder as your **workflow.json** file, which stores the JSON definition for your workflow, and deploys the file to your logic app resource along with the workflow definition.
46+
- The Azure portal saves your script as a PowerShell script file (*.ps1*) in the same folder as your **workflow.json** file, which stores the JSON definition for your workflow, and deploys the file to your logic app resource along with the workflow definition.
4747

48-
The **.ps1** file format lets you write less "boilerplate" and focus just on writing PowerShell code. If you rename the action, the file is also renamed, but not vice versa. If you directly rename the file, the renamed version overwrites the previous version. If the action name and file names don't match, the action can't find the file and tries to create a new empty file.
48+
The *.ps1* file format lets you write less "boilerplate" and focus just on writing PowerShell code. If you rename the action, the file is also renamed, but not vice versa. If you directly rename the file, the renamed version overwrites the previous version. If the action name and file names don't match, the action can't find the file and tries to create a new empty file.
4949

5050
- The script is local to the workflow. To use the same script in other workflows, [view the script file in the **KuduPlus** console](#view-script-file), and then copy the script to reuse in other workflows.
5151

@@ -60,7 +60,7 @@ This guide shows how to add the action in your workflow and add the PowerShell c
6060

6161
1. In the [Azure portal](https://portal.azure.com), open your Standard logic app resource and workflow in the designer.
6262

63-
1. In the designer, [follow these general steps to add the **Inline Code Operations** action named **Execute PowerShell Code** to your workflow](create-workflow-with-trigger-or-action.md?tabs=standard#add-action).
63+
1. In the designer, add the **Inline Code Operations** action named **Execute PowerShell Code** to your workflow. For detailed steps, see [Add an action to run a task](add-trigger-action-workflow.md?tabs=standard#add-action).
6464

6565
1. After the action information pane opens, on the **Parameters** tab, in the **Code File** box, update the prepopulated sample code with your own code.
6666

@@ -107,7 +107,7 @@ After you run your workflow, you can review the workflow output in Application I
107107

108108
## Access workflow trigger and action outputs in your script
109109

110-
The output values from the trigger and preceding actions are returned using a custom object, which has multiple parameters. To access these outputs and make sure that you return the value that you want, use the [**Get-TriggerOutput**](#get-triggeroutput), [**Get-ActionOutput**](#get-actionoutput), and [**Push-WorkflowOutput**](#push-workflowoutput) cmdlets plus any appropriate parameters described in the following table, for example:
110+
The output values from the trigger and preceding actions are returned using a custom object, which has multiple parameters. To access these outputs and make sure that you return the value that you want, use the [Get-TriggerOutput](#get-triggeroutput), [Get-ActionOutput](#get-actionoutput), and [Push-WorkflowOutput](#push-workflowoutput) cmdlets plus any appropriate parameters described in the following table, for example:
111111

112112
```powershell
113113
$trigger = Get-TriggerOutput
@@ -121,34 +121,34 @@ Push-WorkflowOutput -Output $populatedString
121121

122122
> [!NOTE]
123123
>
124-
> In PowerShell, if you reference an object that has **JValue** type inside a complex object, and you
125-
> add that object to a string, you get a format exception. To avoid this error, use **ToString()**.
124+
> In PowerShell, if you reference an object that has *JValue* type inside a complex object, and you
125+
> add that object to a string, you get a format exception. To avoid this error, use `ToString()`.
126126
127127
### Trigger and action response outputs
128128

129-
The following table lists the outputs that are generated when you call **Get-ActionOutput** or **Get-TriggerOutput**. The return value is a complex object called **PowershellWorkflowOperationResult**, which contains thee following outputs.
129+
The following table lists the outputs that are generated when you call `Get-ActionOutput` or `Get-TriggerOutput`. The return value is a complex object called `PowershellWorkflowOperationResult`, which contains the following outputs.
130130

131131
| Name | Type | Description |
132132
|------|------|-------------|
133-
| **Name** | String | The name for the trigger or action. |
134-
| **Inputs** | JToken | The input values passed into the trigger or action. |
135-
| **Outputs** | JToken | The outputs from the executed trigger or action. |
136-
| **StartTime** | DateTime | The start time for the trigger or action. |
137-
| **EndTime** | DateTime | The end time for the trigger or action. |
138-
| **ScheduledTime** | DateTime | The scheduled time to run the trigger or action or trigger. |
139-
| **OriginHistoryName** | String | The origin history name for triggers with the **Split-On** option enabled. |
140-
| **SourceHistoryName** | String | The source history name for a resubmitted trigger. |
141-
| **TrackingId** | String | The operation tracking ID. |
142-
| **Code** | String | The status code for the result. |
143-
| **Status** | String | The run status for the trigger or action, for example, **Succeeded** or **Failed**. |
144-
| **Error** | JToken | The HTTP error code. |
145-
| **TrackedProperties** | JToken | Any tracked properties that you set up. |
133+
| **Name** | String | The name for the trigger or action |
134+
| **Inputs** | JToken | The input values passed into the trigger or action |
135+
| **Outputs** | JToken | The outputs from the executed trigger or action |
136+
| **StartTime** | DateTime | The start time for the trigger or action |
137+
| **EndTime** | DateTime | The end time for the trigger or action |
138+
| **ScheduledTime** | DateTime | The scheduled time to run the trigger or action or trigger |
139+
| **OriginHistoryName** | String | The origin history name for triggers with the `SplitOn` option enabled |
140+
| **SourceHistoryName** | String | The source history name for a resubmitted trigger |
141+
| **TrackingId** | String | The operation tracking ID |
142+
| **Code** | String | The status code for the result |
143+
| **Status** | String | The run status for the trigger or action, for example, "Succeeded" or "Failed" |
144+
| **Error** | JToken | The HTTP error code |
145+
| **TrackedProperties** | JToken | Any tracked properties that you set up |
146146

147147
<a name="return-data-to-workflow"></a>
148148

149149
## Return outputs to your workflow
150150

151-
To return any outputs to your workflow, you must use the [**Push-WorkflowOutput** cmdlet](#push-workflowoutput).
151+
To return any outputs to your workflow, you must use the [Push-WorkflowOutput cmdlet](#push-workflowoutput).
152152

153153
## Custom PowerShell commands
154154

@@ -170,7 +170,7 @@ None.
170170

171171
### Get-ActionOutput
172172

173-
Gets the output from another action in the workflow and returns an object named **PowershellWorkflowOperationResult**.
173+
Gets the output from another action in the workflow and returns an object named `PowershellWorkflowOperationResult`.
174174

175175
#### Syntax
176176

@@ -190,8 +190,8 @@ Pushes output from the **Execute PowerShell Code** action to your workflow, whic
190190

191191
> [!NOTE]
192192
>
193-
> The **Write-Debug**, **Write-Host**, and **Write-Output** cmdlets don't return values
194-
> to your workflow. The **return** statement also doesn't return values to your workflow.
193+
> The `Write-Debug`, `Write-Host`, and `Write-Output` cmdlets don't return values
194+
> to your workflow. The `return` statement also doesn't return values to your workflow.
195195
> However, you can use these cmdlets to write trace messages that appear in Application Insights.
196196
> For more information, see [Microsoft.PowerShell.Utility](/powershell/module/microsoft.powershell.utility).
197197
@@ -205,8 +205,8 @@ Push-WorkflowOutput [-Output <Object>] [-Clobber]
205205

206206
| Parameter | Type | Description |
207207
|-----------|------|-------------|
208-
| **Output** | Varies. | The output that you want to return to the workflow. This output can have any type. |
209-
| **Clobber** | Varies. | An optional switch parameter that you can use to override the previously pushed output. |
208+
| **Output** | Varies | The output that you want to return to the workflow. This output can have any type. |
209+
| **Clobber** | Varies | An optional switch parameter that you can use to override the previously pushed output. |
210210

211211
## Authenticate and authorize access with a managed identity using PowerShell
212212

@@ -216,7 +216,7 @@ From inside the **Execute PowerShell Code** action, you can authenticate and aut
216216

217217
To use the managed identity from inside the **Execute PowerShell Code** action, you must follow these steps:
218218

219-
1. [Follow these steps to set up the managed identity on your logic app and grant the managed identity access on the target Azure resource](authenticate-with-managed-identity.md?tabs=standard).
219+
1. Set up the managed identity on your logic app and grant the managed identity access on the target Azure resource. To learn how, see [Authenticate access and connections to Azure resources with managed identities](authenticate-with-managed-identity.md?tabs=standard).
220220

221221
On the target Azure resource, review the following considerations:
222222

@@ -248,15 +248,15 @@ To use the managed identity from inside the **Execute PowerShell Code** action,
248248

249249
1. Go to your logic app's root location: **site/wwwroot**
250250

251-
1. Go to your workflow's folder, which contains the .ps1 file, along this path: **site/wwwroot/{workflow-name}**
251+
1. Go to your workflow's folder, which contains the *.ps1* file, along this path: **site/wwwroot/{workflow-name}**
252252

253253
1. Next to the file name, select **Edit** to open and view the file.
254254

255255
<a name="log-output-application-insights"></a>
256256

257257
## View logs in Application Insights
258258

259-
1. In the [Azure portal](https://portal.azure.com), on the logic app resource menu, under **Settings**, select **Application Insights**, and then select your logic app.
259+
1. In the [Azure portal](https://portal.azure.com), under **Monitoring** on the logic app resource menu, select **Application Insights**, and then select your logic app.
260260

261261
1. On the **Application Insights** menu, under **Monitoring**, select **Logs**.
262262

@@ -299,7 +299,7 @@ To find publicly available modules, visit the [PowerShell gallery](https://www.p
299299
}
300300
```
301301

302-
1. Open the file named **requirements.psd1**. Include the name and version for the module that you want by using the following syntax: **MajorNumber.\*** or the exact module version, for example:
302+
1. Open the file named **requirements.psd1**. Include the name and version for the module that you want by using the following syntax: `MajorNumber.*` or the exact module version, for example:
303303

304304
```powershell
305305
@{
@@ -332,7 +332,7 @@ You can generate your own private PowerShell modules. To create your first Power
332332

333333
1. In the **Modules** folder, create a subfolder with the same name as your private module.
334334

335-
1. In your private module folder, add your private PowerShell module file with the **psm1** file name extension. You can also include an optional PowerShell manifest file with the **psd1** file name extension.
335+
1. In your private module folder, add your private PowerShell module file with the *psm1* file name extension. You can also include an optional PowerShell manifest file with the *psd1* file name extension.
336336

337337
When you're done, your complete logic app file structure appears similar to the following example:
338338

@@ -359,13 +359,13 @@ In this release, the web-based editor includes limited IntelliSense support, whi
359359

360360
### A workflow action doesn't return any output.
361361

362-
Make sure that you use the **Push-WorkflowOutput** cmdlet.
362+
Make sure that you use the `Push-WorkflowOutput` cmdlet.
363363

364364
### Execute PowerShell Code action fails: "The term '{some-text}' is not recognized..."
365365

366366
If you incorrectly reference a public module in the **requirements.psd1** file or when your private module doesn't exist in the following path: **C:\home\site\wwwroot\Modules\{module-name}**, you get the following error:
367367

368-
**The term '{some-text}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name or if a path was included, verify the path is correct and try again.**
368+
**"The term '{some-text}' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name or if a path was included, verify the path is correct and try again."**
369369

370370
> [!NOTE]
371371
>
@@ -374,7 +374,7 @@ If you incorrectly reference a public module in the **requirements.psd1** file o
374374
375375
### Execute PowerShell Code action fails: "Cannot bind argument to parameter 'Output' because it is null."
376376

377-
This error happens when you try to push a null object to the workflow. Confirm whether the object that you're sending with **Push-WorkflowOutput** isn't null.
377+
This error happens when you try to push a null object to the workflow. Confirm whether the object that you're sending with `Push-WorkflowOutput` isn't null.
378378

379379
## Related content
380380

0 commit comments

Comments
 (0)