# Import AzureAD module
Import-Module AzureAD
# Login to Azure AD
Connect-AzureAD
# Path to the CSV file containing GroupDisplayNames
$csvFilePath = "C:\path\to\your\file.csv"
# Import CSV file
$groups = Import-Csv -Path $csvFilePath
# Enterprise App ObjectId
$enterpriseAppObjectId = "your-enterprise-app-objectid"
# Loop through each group in the CSV and add it to the enterprise app
foreach ($group in $groups) {
$groupDisplayName = $group.GroupDisplayNames
# Get the group object by display name
$groupObject = Get-AzureADGroup -Filter "DisplayName eq '$groupDisplayName'"
if ($groupObject -ne $null) {
# Add the group to the enterprise app
Add-AzureADGroupMember -ObjectId $enterpriseAppObjectId -RefObjectId $groupObject.ObjectId
Write-Host "Group '$groupDisplayName' added to the enterprise app."
} else {
Write-Host "Group '$groupDisplayName' not found."
}
}
# Logout from Azure AD
Disconnect-AzureAD
GET https://graph.microsoft.com/v1.0/servicePrincipals?$filter=preferredSingleSignOnMode eq 'saml'&$select=appDisplayName,preferredSingleSignOnMode