'Azure PowerShell add User or Group to Service Principal

how can i add users or a group to a service principal in azure with powershell?

My Service Principal:

$servicePrincipal = Get-AzADServicePrincipal -DisplayName "My Application"

i want to add the user [email protected] or the group "IT" to this service principal.

EDIT: Or the AppRoleAssignmentRequired set to "false" would be fine too.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source