Let’s discuss the new possibilities, such as starting, stopping, or deallocating VMs with Inline PowerShell in Azure Logic Apps. The new inline PowerShell action in Logic Apps opens up exciting possibilities by allowing you to integrate PowerShell scripts directly into your workflows.
You can now easily handle more complex tasks. The Inline PowerShell Action lets you add and run PowerShell scripts inside your Logic Apps Standard workflows. You can write and execute scripts directly in the workflow designer without extra services.
It also allows you to use data from earlier steps in your scripts and pass the results to later actions. This preview feature is a significant upgrade for automating and managing workflows.
The new inline PowerShell action in Logic Apps makes automating tasks, handling data, and linking different systems more straightforward. It simplifies the process of building powerful workflows to meet your specific requirements.
Table of Contents
What is the Role of PowerShell in Workflow Automation?
PowerShell is a powerful scripting language that automates and manages various tasks within workflows. Embedding scripts directly into workflows allows for complex operations and integrations.
New Possibilities with Inline PowerShell in Azure Logic Apps
Adding the inline PowerShell action in Azure Logic Apps marks a significant improvement, allowing for more advanced and interconnected workflows. With this new feature, you can efficiently manage Azure resources, carry out administrative tasks, and automate intricate processes.
- PowerShell Script to Create a Local Admin Account using Intune
- Create Microsoft Entra ID Users with PowerShell Script
- Microsoft is Killing AzureAD MSOnline Powershell Modules
This post provides all the details about the new inline PowerShell action. It enhances Logic Apps’ flexibility by allowing users to embed PowerShell scripts directly into their workflows. The table below shows the key benefits of the feature.
Benefits | Details |
---|---|
Management and cost | Integrating PowerShell scripts directly into your workflow simplifies management and reduces costs by eliminating the need for separate services. |
Dedicated Scripting Space | Creates a dedicated .ps1 file for your scripts, offering a customized scripting environment within your workflow. |
Seamless Deployment | Scripts are included with your workflow, ensuring they run smoothly and efficiently without extra steps. |
Support for Modules | supports up to 10 public modules from the PowerShell Gallery, such as Az or SqlServer, and allows you to create and use private modules for tailored functionality. This enhances code reuse and makes your workflows easier to maintain. |
Automated Bank Reconciliation Workflow
To demonstrate the power of the new inline PowerShell feature, here’s what the bank reconciliation workflow does. Before you begin, it is essential to ensure you have the setup, such as the Azure VM with RDP and
Azure Storage Account.
The below list shows more details.
- Automates Reconciliation – Uses inline PowerShell scripts to manage the reconciliation process.
- Starts and stops virtual machines (VMs) as part of the workflow.
- Runs on a set schedule to perform tasks at regular intervals.
- Searches for required files and uploads them to storage.
- Alerts the team if files are missing, prompting resolution.
- 3 Best Methods to Import SCCM PowerShell Module Cmdlets
- Intune Policy Assignment Classification Easy Secrets of using Graph API with PowerShell
- Manage Intune Tasks with PowerShell Part 1
Workflow Operation or Functions
Trigger the Workflow (Recurrence) – The process begins with a scheduled trigger that regularly starts the bank reconciliation workflow. Next, the inline PowerShell action starts a virtual machine (VM), which sets up the required environment for the reconciliation tasks.
- This step ensures the VM is ready to perform the necessary operations, such as file checks and data processing.
List Files in a Folder – After the VM runs, the workflow lists all files and subfolders in a specified directory. This step checks for the necessary reconciliation files within the designated folder path on the server.
Iterate Over Files (For Each Loop) – The workflow processes each file individually by looping through all the files in the folder. To do this, use the “Folder items” parameter in the token picker, allowing the workflow to handle each file individually.
Condition Check
Let’s discuss the Condition Check. The workflow includes a condition to verify whether the required files are present. There are two conditions: True path and False path. The table below gives more details.
True Path | False Path |
---|---|
If the files are found, the workflow proceeds to retrieve the file contents and upload them to a storage container for further processing or archival. This is done using the File System connector’s “Get file content” operation to access each file and its data. The files are then uploaded to the storage account for the parent bank to process. | If the files are missing, the workflow triggers an email notification to inform the relevant team members that the partner bank did not upload them to the server. |
Deallocate the VM with PowerShell – The workflow includes another inline PowerShell action to deallocate the VM once file processing is complete. This step helps optimize resource usage and reduce costs by shutting down the VM when it is no longer needed.
Running the Workflow to Ensure Smooth Operation
The workflow runs automatically every day. You should upload the bank statements to the VM’s file share folder so the workflow can access and process them daily.
You should adjust the requirements.psd1 File, Comment out the ‘Az’ versioning line in the requirements.psd1 file to allow the script to use the Az module with the correct version. Using Kudu, you can find and edit this file through Advanced Tools in the Azure Portal.
We are on WhatsApp now. To get the latest step-by-step guides, news, and updates, Join our Channel. Click here. HTMD WhatsApp.
Author
Anoop C Nair has been Microsoft MVP from 2015 onwards for 10 consecutive years! He is a Workplace Solution Architect with more than 22+ years of experience in Workplace technologies. He is also a Blogger, Speaker, and Local User Group Community leader. His primary focus is on Device Management technologies like SCCM and Intune. He writes about technologies like Intune, SCCM, Windows, Cloud PC, Windows, Entra, Microsoft Security, Career, etc.