enter image description here

See my Azure Portal. I'm looking to add the "Reader" role my service principal. How would I do this in Powershell?

1

There are 1 best solutions below

0
Sridevi On BEST ANSWER

You can make use of below PowerShell command to add Reader role to the service principal under subscription:

$spId = (Get-AzADServicePrincipal -DisplayName "sp_Name").id
$subscriptionId = "your_subscription_Id"

New-AzRoleAssignment -ObjectId $spId `
-RoleDefinitionName "Reader" `
-Scope "/subscriptions/$subscriptionId"

Response:

enter image description here

To confirm that, I checked the same in Portal where Reader role added successfully to service principal under subscription level like this:

enter image description here