Using KQL in a Playbook for Sentinel (2024)

I was working with a customer recently and they wanted to run a playbook in Microsoft Sentinel that would take an incident and look to see if the accounts in the incident were enable or disabled and then send an email to the security team giving them that information.

I ran into a few bumps on the road before I figured it out and

Rod Trent

mentioned that it would make a good blog. So here we are.

To create the new playbook, go into Sentinel and select the Automation blade. Once there, hit the “Create” button at the top and click “Playbook with Incident trigger”.

Using KQL in a Playbook for Sentinel (1)

Give it a name and click through to “Review and create” and create the playbook. Once the logic app is created, we can go in and start configuring. Underneath the Microsoft Sentinel Incident trigger, hit the + sign and “Add an action”. In the Search box, type entities and select “Entities – Get Accounts”.

In the Parameters box, click the lightning bolt.

Using KQL in a Playbook for Sentinel (3)

A box will pop up and in the search box type entities and click on “Entities” beneath the Microsoft Sentinel Incident section.

Using KQL in a Playbook for Sentinel (4)

Then, “Add an action” and search for condition. Here you’ll have to select “See more” in the “Control” section and pick “For each”. Click on the “For each” box, select the lightning bolt and search for “Accounts” and select it.

Now the fun starts. Click on the + sign to “Add an action”. Type run query in the search box and select “Run query and list results” in the “Azure Monitor Logs” section. In the Parameters section, input all the data that refers to your Azure environment. You input your KQL query in the Query box. For this particular use case, I’m looking in the IdentityInfo table to find out if in account is enabled or disabled. Here is the query I used.

IdentityInfo| where TimeGenerated >= ago(7d)| where AccountUPN contains ""| summarize arg_max(TimeGenerated, *) by AccountUPN| project IsAccountEnabled

Paste the KQL query in the box and go to the third line of the KQL query that starts with “where AccountUPN contains”. Put your cursor in between the quotation marks. Then select the lightning bolt and select “Accounts Name”. The query is now looking back 7 days for the account “Accounts Name”. It’s finding the most recent entry in the table and bringing back the value of IsAccountEnabled.

Now, add another For each condition via the “Add an action” button. In the Parameters box, click on the lightning bolt and select value. This is taking the results of the KQL query that you just ran soyou can use it so show if the user is enabled or not. The value that we get is in JSON, so the next step is to parse the JSON.

“Add an action” and search for parse json. Select “Parse JSON” beneath the “Data operations” section. In the Content box, select the lightning bolt and pick “current item” in the For each 1 section. In the Schema box, paste this.

{ "properties": { "IsAccountEnabled": { "type": "boolean" } }, "type": "object"}

It’s telling the logic app what to do with the KQL query output. I had a little trouble with this one. It took me a while to figure out the right way to do the parsing.

Using KQL in a Playbook for Sentinel (6)

Now it’s time to add one more condition. Click “Add an action” and search for condition. Select “Condition” under the Control section.

Using KQL in a Playbook for Sentinel (7)

Click on the “Condition” box. In the first box that says Choose a value, select the lightning bolt then click on “Body IsAccountEnabled” in the Parse JSON section. In the second box, select “is equal to”. In the last box, type true. I also had a little trouble here. I thought it would be easier to do a “contains” instead of “is equal to” and I was very wrong.

Using KQL in a Playbook for Sentinel (8)

We now have two actions that can happen based on whether the condition is true or not. In my use case, if the condition was true (theuser account was enabled) we sent an email to the security team that read “User XYZ is enabled”. And if the account was disabled, we sent one saying “User account is disabled”. But you could do lots of other things.

You could add a comment to the incident so the person working the case has more information.

You could add a task to the incident telling the analyst what next steps they should take.

You could add the user to a watchlist.

You could feed the information in to another KQL query to get even more information.

It’s really up to you!

Here is a look at the completed playbook.

Using KQL in a Playbook for Sentinel (9)
Using KQL in a Playbook for Sentinel (2024)
Top Articles
The Multiple Bank Accounts You Need to Budget Better
How to Get Started If You’ve Never Had a Bank Account - NerdWallet
Katie Pavlich Bikini Photos
Gamevault Agent
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Free Atm For Emerald Card Near Me
Craigslist Mexico Cancun
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Doby's Funeral Home Obituaries
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Select Truck Greensboro
Things To Do In Atlanta Tomorrow Night
Non Sequitur
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Craigslist In Flagstaff
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Testberichte zu E-Bikes & Fahrrädern von PROPHETE.
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Walgreens Alma School And Dynamite
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Rogold Extension
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Weekly Math Review Q4 3
Facebook Marketplace Marrero La
Nobodyhome.tv Reddit
Topos De Bolos Engraçados
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hampton In And Suites Near Me
Stoughton Commuter Rail Schedule
Bedbathandbeyond Flemington Nj
Free Carnival-themed Google Slides & PowerPoint templates
Otter Bustr
Selly Medaline
Latest Posts
Article information

Author: Foster Heidenreich CPA

Last Updated:

Views: 5996

Rating: 4.6 / 5 (76 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Foster Heidenreich CPA

Birthday: 1995-01-14

Address: 55021 Usha Garden, North Larisa, DE 19209

Phone: +6812240846623

Job: Corporate Healthcare Strategist

Hobby: Singing, Listening to music, Rafting, LARPing, Gardening, Quilting, Rappelling

Introduction: My name is Foster Heidenreich CPA, I am a delightful, quaint, glorious, quaint, faithful, enchanting, fine person who loves writing and wants to share my knowledge and understanding with you.