How can I get the ObjectID from the specific Azure object I entered based on the display name?
The input can be Azure AD App, Azure AD group, or any object type.
$objID = ....
I require this to simplify the below script:
New-AzRoleAssignment -ObjectId $objID `
-RoleDefinitionName "Contributor" `
-ResourceGroupName "newly-created-resource-group"
After reproducing from my end, I could able to get the object ID using Get-AzureADApplication
. Below is the PowerShell script that worked for me.
$objID = Get-AzureADApplication -Filter "DisplayName eq '<YourDisplayName>'"
$objID.ObjectId
RESULTS: