While PowerShell can handle a seemingly unlimited number of administrative tasks, messaging isn't one of its strong suits.
It takes work to get the right modules configured and authenticated to set up notifications in PowerShell. If you want to get messages from scripts that run in multiple locations in your organization, then the setup process is even more complicated. For example, you might have scheduled scripts that run on the domain controllers and want the script to report any success or failure. Or, more simply, you may want an easier way to deploy scripts with a smaller footprint. One option that can help with these specialized automation jobs is to use Azure Logic Apps to accept an HTTP POST and send an email or message in Microsoft Teams.
First, log into the Azure portal, click the Create a Resource button, search for Logic App and click on the Create button.
In the Create Logic App pane, select your resource group or create a new one if needed, set your type appropriately -- use Consumption unless you need Standard -- and give it a name:
Add any tags and create it. Select Go to Resource.
The first page that opens when you create an Azure Logic App contains some common triggers. For this Azure Logic Apps tutorial, we will use the When a HTTP request is received request trigger for the configuration of both Microsoft Teams and email.
The power of Azure Logic Apps is its ease of use. To demonstrate, let's create an automated workflow with two steps. First, it will accept several parameters via the When a HTTP request is received action and then it will send an email. This tutorial will use the Office 365 email connector, but there are several other email connectors with a send-email action, such as the Gmail connector for Google's email service. Microsoft provides a full list of its Logic Apps connectors here.
For a more flexible workflow, this Azure Logic App should accept values for several email header fields, such as to, CC, BCC, subject and message. To tell the Azure Logic App how to pass the data, we format that object in JavaScript Object Notation (JSON) and input it as a sample payload.
The Azure Logic App uses the values you supply to determine what type the property is.
Click on Use sample payload to generate schema and paste the JSON payload.
Click Done and you should see that the JSON schema updates to a format that is compatible with the Azure Logic App.
Add the email action by clicking on New Step and search for your email provider. For the purposes of this tutorial, search for Office 365 Outlook and select the Send an email (V2) action. If you haven't set up authentication for this action, a dialog box will prompt you to sign into an account. If you don't want to use your email account, then either sign in with a service account, or use the From parameter or select the Send an email from a shared mailbox (V2) and use a shared mailbox.
After authentication setup, the action will appear on the workflow.
You might notice the workflow doesn't have all the email header fields. Add those by clicking on the Add new parameter drop-down and check the parameters to add.
To use our defined parameters, click on one of the boxes, such as To, and a pop-up will suggest values that are hidden until you click the See more to reveal the custom parameters.
For each parameter, select the matching value from the list. For Body, I used the name Message to avoid confusion with the other Body value.
Click Save to check the Azure Logic App.
To check the workflow, we need its HTTP POST URL that calls the Azure Logic App. Open the When a HTTP request is received action to find it.
If there is no value in the HTTP POST URL box, try saving the workflow.
Next, copy the value, open a PowerShell script editor and assign the URL to a variable. Next, create the parameters to send to the Azure Logic App by creating a hashtable and using ConvertTo-Json:
If you use Windows PowerShell v5.1, you need to specify the Content-Type of the message manually:
If you use PowerShell 7, you can do that with the ContentType parameter on the Invoke-RestMethod command.
Next, run the Invoke-RestMethod command by using a splat to collect the parameter values.
The finished script looks like the following:
Run a test by sending an email to yourself.
If the email doesn't arrive, check for errors in the run history on the Azure Logic App.
Microsoft Teams has grown to be one of the more popular communications platforms for enterprises, and it's adaptable enough for use with Azure Logic Apps for automated messaging.
To start with this example workflow, set up the When a HTTP request is received action with a sample JSON payload of:
For the first action, search for Microsoft Teams and select the List channels action. Then select a team name. This returns the channels associated with that team.
To find a channel by name and get the ID, click the plus sign to add an action and then scroll to the Choose an operation box. Click the Data Operations Built-in icon.
Locate Filter array from the list. From the dynamic fields, add Channel List in the From section and set the Channel Name as equal to the Channel value from the HTTP POST action.
Next, add a for-each loop by scrolling down in the Choose an operation box, then select Control.
Choose the For each action. For the Select an output from previous steps parameter, choose the Body option from filter array.
You can select Add an action inside the for-each loop that will run for each channel that matches the name that was passed. This should be either 1 or 0.
From there, select Microsoft Teams and the Post message in a chat or channel action.
For the Team parameter, select the same team used in the List channels action.
Then for the Channel, you'll want to select the Enter custom value option.
From the dynamic content, you should see Channel Id under filter array.
Select that value and then set the message to the Message property from the When a HTTP request is received trigger.
Save the workflow to keep your progress. Run a test with a slightly modified version of the script used in the email automated workflow.
If successful, a message will appear in the Microsoft Teams channel.
Microsoft Azure Logic Apps simplifies automated messaging to make it easier to deploy to various places in your infrastructure. You will no longer worry about configuring extra modules to handle authentication to Exchange Online or Microsoft Teams or enabling SMTP authentication and then having to explain yourself to the security team.
The added benefit is your script can scale to the capacity of Azure, so sending out hundreds of emails in a single run will not overwhelm the system. You will have one less concern about your infrastructure and more time to think about the work that matters.
Follow this link:
Send automated messages with this Azure Logic Apps tutorial - TechTarget
- Automation Personnel Services - Temporary Staffing ... [Last Updated On: March 25th, 2016] [Originally Added On: March 25th, 2016]
- Automation | Define Automation at Dictionary.com [Last Updated On: March 25th, 2016] [Originally Added On: March 25th, 2016]
- Automation | Definition of automation by Merriam-Webster [Last Updated On: March 25th, 2016] [Originally Added On: March 25th, 2016]
- Automation | The Car Company Tycoon Game [Last Updated On: March 25th, 2016] [Originally Added On: March 25th, 2016]
- Automation - Wikipedia, the free encyclopedia [Last Updated On: March 25th, 2016] [Originally Added On: March 25th, 2016]
- Automation - Cloud process & workflow automation | Microsoft ... [Last Updated On: June 29th, 2016] [Originally Added On: June 29th, 2016]
- Riverside Automation - Machine Controls [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- Automation: The Car Company Tycoon Game Windows - Mod DB [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- System Integration | Industrial Automation [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- WinAutomation - Smart Macro Recorder, Web Automation ... [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- Automation Solutions - Home [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- The Automation Conference [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- Rohtek Automation [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- JL Automation, LLC | Home Automation, A/V Automation [Last Updated On: July 3rd, 2016] [Originally Added On: July 3rd, 2016]
- Four fundamentals of workplace automation | McKinsey & Company [Last Updated On: August 27th, 2016] [Originally Added On: August 27th, 2016]
- Leviton Security & Home Automation [Last Updated On: August 27th, 2016] [Originally Added On: August 27th, 2016]
- EVA Automation [Last Updated On: September 6th, 2016] [Originally Added On: September 6th, 2016]
- News | Automation | The Car Company Tycoon Game [Last Updated On: September 6th, 2016] [Originally Added On: September 6th, 2016]
- Automation - The Car Company Tycoon Game on Steam [Last Updated On: September 6th, 2016] [Originally Added On: September 6th, 2016]
- Test automation - Wikipedia, the free encyclopedia [Last Updated On: September 6th, 2016] [Originally Added On: September 6th, 2016]
- Job Seekers - Automation Personnel Services [Last Updated On: October 8th, 2016] [Originally Added On: October 8th, 2016]
- Custom Automation & Machine Design | Automation GT [Last Updated On: October 31st, 2016] [Originally Added On: October 31st, 2016]
- iAutomation [Last Updated On: October 31st, 2016] [Originally Added On: October 31st, 2016]
- Test automation - Wikipedia [Last Updated On: November 16th, 2016] [Originally Added On: November 16th, 2016]
- Automation - Official Site [Last Updated On: November 19th, 2016] [Originally Added On: November 19th, 2016]
- Beckhoff Automation - Wikipedia [Last Updated On: November 21st, 2016] [Originally Added On: November 21st, 2016]
- Automation - Security Hyperstore [Last Updated On: November 21st, 2016] [Originally Added On: November 21st, 2016]
- IT Automation - BMC [Last Updated On: November 29th, 2016] [Originally Added On: November 29th, 2016]
- ID Automation [Last Updated On: November 29th, 2016] [Originally Added On: November 29th, 2016]
- The Best Home Automation Systems of 2016 | Top Ten Reviews [Last Updated On: December 24th, 2016] [Originally Added On: December 24th, 2016]
- What is Home Automation? | Home Automation Systems [Last Updated On: December 24th, 2016] [Originally Added On: December 24th, 2016]
- Beyond Automation - hbr.org [Last Updated On: December 25th, 2016] [Originally Added On: December 25th, 2016]
- Build automation - Wikipedia [Last Updated On: December 26th, 2016] [Originally Added On: December 26th, 2016]
- Home automation - Wikipedia [Last Updated On: January 10th, 2017] [Originally Added On: January 10th, 2017]
- Automation | Food Engineering [Last Updated On: January 13th, 2017] [Originally Added On: January 13th, 2017]
- Home Automation - Enerwave Home Automation [Last Updated On: January 14th, 2017] [Originally Added On: January 14th, 2017]
- Automation - DESHAZO [Last Updated On: January 14th, 2017] [Originally Added On: January 14th, 2017]
- Robots, Automation, EOAT, Grippers, Conveyors, Guarding [Last Updated On: January 26th, 2017] [Originally Added On: January 26th, 2017]
- Werner Electric | Automation [Last Updated On: January 28th, 2017] [Originally Added On: January 28th, 2017]
- Automationtechies | Automation Engineering Recruiting [Last Updated On: January 28th, 2017] [Originally Added On: January 28th, 2017]
- Automation - Mazak Corporation [Last Updated On: January 28th, 2017] [Originally Added On: January 28th, 2017]
- Automation | Technologies | Systems | Integrator ... [Last Updated On: January 28th, 2017] [Originally Added On: January 28th, 2017]
- Test Automation Services for Development of Regression ... [Last Updated On: January 28th, 2017] [Originally Added On: January 28th, 2017]
- Carlo Gavazzi Automation Components [Last Updated On: January 30th, 2017] [Originally Added On: January 30th, 2017]
- UI Automation Overview - msdn.microsoft.com [Last Updated On: February 5th, 2017] [Originally Added On: February 5th, 2017]
- New telecom transformation goals require service automation - TechTarget [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Global Hazardous Waste Handling Automation Market: By Products ... - Business Wire (press release) [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- 2M Automation wins IoT support from Schneider - Electronics EETimes (registration) [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Futures Shaped by Automation and Catastrophe: Peter Frase on Capitalism's Endgame - Truth-Out [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Automation expected to displace insurance underwriters, real estate brokers - CIO Dive [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Automation, robots could replace 250000 public sector workers in the next 15 years - Computer Business Review [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Design Automation Conference - Business Wire (press release) [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- The Perks Of Automation And The Risks: Why To Think Twice About Getting Into That Driverless Uber - Forbes [Last Updated On: February 6th, 2017] [Originally Added On: February 6th, 2017]
- Lib Dems Should Embrace Automation of the Workforce - Liberal Democrat Voice [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Voices Reinventing enterprise finance by overhauling AP automation - Accounting Today [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- How Accountants Can Use Automation Their Advantage - Accountingweb.com (blog) [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- DFLabs Launches the First Security Automation and Orchestration Platform based Upon Supervised Active Intelligence - Business Wire (press release) [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- QAD Automation Solutions is Honda Approved - Yahoo Finance [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- VIDEO: Going Big on Automation in a Small Footprint Facility - ENGINEERING.com [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Building a better model of human-automation interaction - Phys.Org [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- AlixPartners examines automation in manufacturing and logistics management - Logistics Management [Last Updated On: February 7th, 2017] [Originally Added On: February 7th, 2017]
- Report: Test automation is increasing - SD Times - SDTimes.com [Last Updated On: February 9th, 2017] [Originally Added On: February 9th, 2017]
- Automation is the unavoidable future of the economy - The Daily Cougar [Last Updated On: February 9th, 2017] [Originally Added On: February 9th, 2017]
- GM's Cruise Automation Is Testing An App to Order Self-Driving ... - Fortune [Last Updated On: February 9th, 2017] [Originally Added On: February 9th, 2017]
- Speeders beware: Legislation would allow automation crackdown ... - SFGate [Last Updated On: February 9th, 2017] [Originally Added On: February 9th, 2017]
- Orbita Ingenieria: New Age Terminal Automation - Port Technology International [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- A Sharper Focus on the Edge - Automation World [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- Rockwell Automation Surged 10% in January as Growth Picked Up Steam - Motley Fool [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- Most people are optimistic about workplace automation, social data suggests - ZDNet [Last Updated On: February 10th, 2017] [Originally Added On: February 10th, 2017]
- Improving Behavior Through Automation of Vehicle Systems - School Transportation News (blog) [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- 'We employ insane levels of automation' Kris Canekeratne - Times of India [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- Why Don't We See More Automation in Federal Networks? - Nextgov [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- Technobabble: Automation and the modern worker - CIO Dive [Last Updated On: February 11th, 2017] [Originally Added On: February 11th, 2017]
- Readers Write (Feb. 12): The moose population; jobs, start-ups and automation; diversity in the funny pages - Minneapolis Star Tribune [Last Updated On: February 12th, 2017] [Originally Added On: February 12th, 2017]
- Automation Nightmare: Philosopher Warns We Are Creating a World Without Consciousness - Big Think [Last Updated On: February 12th, 2017] [Originally Added On: February 12th, 2017]
- Automation can replace bureaucrats and save taxpayers money - Hot Air [Last Updated On: February 12th, 2017] [Originally Added On: February 12th, 2017]
- Automation can revitalize the US workforce - Fox News [Last Updated On: February 12th, 2017] [Originally Added On: February 12th, 2017]
- TigerStop hopes to ride automation to new heights - The Columbian [Last Updated On: February 13th, 2017] [Originally Added On: February 13th, 2017]
- Hexadite Unveils Custom Playbooks Following One Millionth Automated Cybersecurity Investigation - Yahoo Finance [Last Updated On: February 13th, 2017] [Originally Added On: February 13th, 2017]
- NEC updates postal automation system for Hongkong Post - ETCIO.com [Last Updated On: February 13th, 2017] [Originally Added On: February 13th, 2017]