Skip to content

Commit 56e5417

Browse files
authored
Merge pull request Azure#13284 from Azure/v-sabiraj-updatingscriptforplaybook
Update script to use Microsoft.Graph module for Add-IP-Entity-To-Named-Location playbook
2 parents ddf0aae + 4ff9b4b commit 56e5417

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
# This script grants the necessary Microsoft Graph API permissions to the Service Principal.
2-
# Before running, change the $TenantID (line5) to your AAD Tenant ID and the $DisplayNameofMSI (line6) to the name of your Logic App
3-
# This script requires the AzureAD Powershell Module, Install-Module AzureAD
2+
# Before running, change the $TenantID (line5) to your Entra ID Tenant ID and the $DisplayNameofMSI (line6) to the name of your Logic App
3+
# This script requires the Microsoft.Graph PowerShell Module: Install-Module Microsoft.Graph -Scope CurrentUser
44

5-
$TenantID="" #AAD Tenant Id
5+
$TenantID="" #Entra ID Tenant Id
66
$DisplayNameOfMSI="Add-IP-Entity-To-Named-Location" # Name of the managed identity
77

8-
Connect-AzureAD -TenantId $TenantID
8+
Connect-MgGraph -TenantId $TenantID -Scopes "Application.Read.All", "AppRoleAssignment.ReadWrite.All"
99

10-
$MSI = (Get-AzureADServicePrincipal -Filter "displayName eq '$DisplayNameOfMSI'")
10+
$MSI = Get-MgServicePrincipal -Filter "displayName eq '$DisplayNameOfMSI'"
1111

1212
Start-Sleep -Seconds 5
1313

1414
#Microsoft Graph API - Policy.Read.All
1515
$GraphAppId = "00000003-0000-0000-c000-000000000000"
1616
$PermissionName = "Policy.Read.All"
17-
$GraphServicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$GraphAppId'"
17+
$GraphServicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$GraphAppId'"
1818
$AppRole = $GraphServicePrincipal.AppRoles | Where-Object {$_.Value -eq $PermissionName -and $_.AllowedMemberTypes -contains "Application"}
19-
New-AzureAdServiceAppRoleAssignment -ObjectId $MSI.ObjectId -PrincipalId $MSI.ObjectId -ResourceId $GraphServicePrincipal.ObjectId -Id $AppRole.Id
19+
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $MSI.Id -PrincipalId $MSI.Id -ResourceId $GraphServicePrincipal.Id -AppRoleId $AppRole.Id
2020

2121
Start-Sleep -Seconds 5
2222

2323
#Microsoft Graph API - Policy.ReadWrite.ConditionalAccess
2424
$GraphAppId = "00000003-0000-0000-c000-000000000000"
2525
$PermissionName = "Policy.ReadWrite.ConditionalAccess"
26-
$GraphServicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$GraphAppId'"
26+
$GraphServicePrincipal = Get-MgServicePrincipal -Filter "appId eq '$GraphAppId'"
2727
$AppRole = $GraphServicePrincipal.AppRoles | Where-Object {$_.Value -eq $PermissionName -and $_.AllowedMemberTypes -contains "Application"}
28-
New-AzureAdServiceAppRoleAssignment -ObjectId $MSI.ObjectId -PrincipalId $MSI.ObjectId -ResourceId $GraphServicePrincipal.ObjectId -Id $AppRole.Id
28+
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $MSI.Id -PrincipalId $MSI.Id -ResourceId $GraphServicePrincipal.Id -AppRoleId $AppRole.Id
2929

30-
# Disconnect-AzureAD
30+
Disconnect-MgGraph

Playbooks/Add-IP-Entity-To-Named-Location/readme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This playbook will execute using an incident based trigger and add the IP entiti
66

77
## Quick Deployment
88

9-
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FSolutions%2FStandalone%2FPlaybooks%2FAdd-IP-Entity-To-Named-Location%2Fazuredeploy.json) [![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Fmaster%2FSolutions%2FStandalone%2FPlaybooks%2FAdd-IP-Entity-To-Named-Location%2Fazuredeploy.json)
9+
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Frefs%2Fheads%2Fmaster%2FPlaybooks%2FAdd-IP-Entity-To-Named-Location%2Fazuredeploy.json) [![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAzure-Sentinel%2Frefs%2Fheads%2Fmaster%2FPlaybooks%2FAdd-IP-Entity-To-Named-Location%2Fazuredeploy.json)
1010

1111
## Prerequisites
1212

@@ -17,7 +17,7 @@ This playbook will execute using an incident based trigger and add the IP entiti
1717
- Grant the Logic App Managed Identity access to the Microsoft Graph Policy.Read.All & Policy.ReadWrite.ConditionalAccess which can be done with the included PowerShell script [AddApiPermissions.ps1](https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/Solutions/Standalone/Playbooks/Add-IP-Entity-To-Named-Location/AddApiPermissions.ps1)
1818
- Attach this playbook to an **automation rule** so it runs when specified incidents are created.
1919

20-
[Learn more about automation rules](https://docs.microsoft.com/azure/sentinel/automate-incident-handling-with-automation-rules#creating-and-managing-automation-rules)
20+
[Learn more about automation rules](https://raw.githubusercontent.com/Azure/Azure-Sentinel/refs/heads/master/Playbooks/Add-IP-Entity-To-Named-Location/AddApiPermissions.ps1)
2121

2222
## Screenshots
23-
![Designer](https://raw.githubusercontent.com/Azure/Azure-Sentinel/master/Solutions/Standalone/Playbooks/Add-IP-Entity-To-Named-Location/images/designer-light.jpg)
23+
![Designer](https://github.com/Azure/Azure-Sentinel/blob/1b9d62978fc39278c2debbe8bc720b1d08d233d2/Playbooks/Add-IP-Entity-To-Named-Location/images/designer-light.jpg?raw=true)

0 commit comments

Comments
 (0)