You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将PowerShell脚本转换为Logic Apps(第二部分):数据处理实现咨询

How to Implement Your PowerShell Data Processing Logic in Azure Logic Apps

Since you’ve already handled the login/logout flows in Logic Apps, let’s focus on replicating the core data filtering, selection, export, and formatting steps from your PowerShell script. Here’s a step-by-step breakdown of how to map each operation to Logic Apps actions:


Prerequisite

First, ensure you have an HTTP action that retrieves the Grid data (equivalent to your Invoke-RestMethod call to SPDEDMHAPI.GRIDGET). Let’s assume this action is named Get_Grid_Data—we’ll reference its output throughout these steps.


Step 1: Filter Rows Where PR_OWN Equals "SC-CO-001"

This replaces your PowerShell where {$_.PR_OWN -eq "SC-CO-001"} line:

  • Add a Filter Array action (under the Data Operations group).
    • From: Select the Payload array from your HTTP response:
      body('Get_Grid_Data')?['Payload']
    • Condition: Click "Add condition", then set:
      • Left operand: item()?['PR_OWN']
      • Operator: is equal to
      • Right operand: "SC-CO-001"

Step 2: Select Specific Properties

This replicates Select-Object -Property PR_SNAM, PR_OWN, PR_NAME, PR_ADD4, PR_TENR, PR_USER1:

  • Add a Select action (under Data Operations).
    • From: Choose the output of the Filter Array action:
      body('Filter_Array')
    • Map: For each property you need, define a key-value pair:
      • PR_SNAM: item()?['PR_SNAM']
      • PR_OWN: item()?['PR_OWN']
      • PR_NAME: item()?['PR_NAME']
      • PR_ADD4: item()?['PR_ADD4']
      • PR_TENR: item()?['PR_TENR']
      • PR_USER1: item()?['PR_USER1']

Step 3: Export to XML File

Logic Apps doesn’t have a direct equivalent to PowerShell’s Export-Clixml (which uses a proprietary serialization format), but you can generate standard XML and save it to a file:

  1. Convert to XML: Add a Convert to XML action (Data Operations).
    • Content: Select the output of the Select action: body('Select')
    • Root name: Optional (e.g., "Properties" to add a valid root element to your XML)
  2. Save to File: Add a Create File action (use the File System connector with an on-premises gateway for local paths like C:\Test\API\, or Azure File Storage for cloud storage):
    • File path: Test/API/XML_Sample.xml
    • File content: Select the output of the Convert to XML action: body('Convert_to_XML')

Step 4: Format Data as a Table

To replicate Format-Table -AutoSize for logging or visibility:

  • Add a Create HTML Table action (Data Operations).
    • From: Select the output of the Select action: body('Select')
  • You can then use this HTML table in downstream actions:
    • Log it to Azure Monitor with a Log to Azure Monitor action
    • Send it via email using Send Email (V2)
    • Display it in a notification

Notes

  • If you strictly need the exact Clixml format (rare for non-PowerShell use cases), you can wrap the Export-Clixml command in an Azure Function (using the PowerShell runtime) and call it from Logic Apps.
  • Always test each action individually to verify the output matches your expected results.

内容的提问来源于stack exchange,提问作者AlHal

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:43:59