Home » Office 365 » Set-MsolServicePrincipal – Update Properties of a Service Principal

Set-MsolServicePrincipal – Update Properties of a Service Principal

The Set-MsolServicePrincipal cmdlet in PowerShell updates the service principal in Microsoft Office 365.

The syntax to change properties of a service principal in Microsoft Azure Active Directory is given below.

Set-MsolServicePrincipal
   [-ObjectId <Guid>]
   [-AppPrincipalId <Guid>]
   [-DisplayName <String>]
   [-ServicePrincipalNames <String[]>]
   [-AccountEnabled <Boolean>]
   [-Addresses <RedirectUri[]>]
   [-TenantId <Guid>]
   [<CommonParameters>]

In this article, we will discuss how to use the Set-MsolServicePrincipal cmdlet in PowerShell to update the properties of a service principal in Azure Active Directory.

How to Change the Properties of a Service Principal

To change the properties of a service principal in Office 365, use the Set-MsolServicePrincipal command in PowerShell.

# Get the service principal ID
$AppId = (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp/ShellApp.com").AppPrincipalId

# Update the service principal name and display name of service principal
Set-MsolServicePrincipal -AppPrincipalId $AppId -DisplayName "Shell Geek Application" -ServicePrincipalNames @("ShellGeekApp/ShellApp.com", "Shell Geek App")  

The Get-MsolServicePrincipal cmdlet in PowerShell gets an application ID of a service principal name and stores it in the $AppId variable.

The Set-MsolServicePrincipal command uses the -AppPrincipalId parameter to specify the application ID and updates the display name and service principal names.

This change will overwrite the previous settings on a service principal in Azure Active Directory.

How to Change the Addresses on a Service Principal

To change the addresses on a service principal, use the Set-MsolServicePrincipal cmdlet with the -Addresses parameter.

The -Addresses parameter specify the addresses list with which to update and overwrite the existing list.

$AppId = (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp").AppPrincipalId
$a = @()
$a = $a + (Get-MsolServicePrincipal -ServicePrincipalName "ShellGeekApp").Addresses
$a = $a + (New-MsolServicePrincipalAddresses -Value "ShellApp1.com")
$a = $a + (New-MsolServicePrincipalAddresses -Value "ShellApp2.com")
Set-MsolServicePrincipal -AppPrincipalId $AppId -Addresses $a

This command updates the addresses of a service principal “ShellGeekApp“.

Conclusion

I hope the above article on how to use the Set-MsolServicePrincipal cmdlet in PowerShell to update the properties on a service principal is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

New-MsolServicePrincipal

Remove-MsolServicePrincipal

Get-MsolServicePrincipal