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
Five Bedroom Essentials for Your Airbnb - Hometime
Layout 1
Dainty Rascal Io
Celebrity Extra
Nwi Police Blotter
Tv Guide Bay Area No Cable
10 Popular Hair Growth Products Made With Dermatologist-Approved Ingredients to Shop at Amazon
Videos De Mexicanas Calientes
Paketshops | PAKET.net
Ohiohealth Esource Employee Login
Large storage units
Https //Advanceautoparts.4Myrebate.com
Immediate Action Pathfinder
Superhot Unblocked Games
Craigslist Pets Longview Tx
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Mzinchaleft
Tygodnik Polityka - Polityka.pl
Effingham Bookings Florence Sc
Mahpeople Com Login
How to Watch the Fifty Shades Trilogy and Rom-Coms
EASYfelt Plafondeiland
Dwc Qme Database
Great Clips Grandview Station Marion Reviews
Putin advierte que si se permite a Ucrania usar misiles de largo alcance, los países de la OTAN estarán en guerra con Rusia - BBC News Mundo
Mtr-18W120S150-Ul
Haunted Mansion Showtimes Near Epic Theatres Of West Volusia
Rogue Lineage Uber Titles
Dei Ebill
Synergy Grand Rapids Public Schools
Is Henry Dicarlo Leaving Ktla
Alternatieven - Acteamo - WebCatalog
Deleted app while troubleshooting recent outage, can I get my devices back?
Xemu Vs Cxbx
Best Weapons For Psyker Darktide
KITCHENAID Tilt-Head Stand Mixer Set 4.8L (Blue) + Balmuda The Pot (White) 5KSM175PSEIC | 31.33% Off | Central Online
Sabrina Scharf Net Worth
Hireright Applicant Center Login
3 bis 4 Saison-Schlafsack - hier online kaufen bei Outwell
Wilson Tire And Auto Service Gambrills Photos
Memberweb Bw
Tommy Bahama Restaurant Bar & Store The Woodlands Menu
Lyons Hr Prism Login
Booknet.com Contract Marriage 2
Sacramentocraiglist
Bonecrusher Upgrade Rs3
Lebron James Name Soundalikes
Is Chanel West Coast Pregnant Due Date
Skyward Login Wylie Isd
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
How to Find Mugshots: 11 Steps (with Pictures) - wikiHow
Att Corporate Store Location
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.