New-AzADSpCredential

In this Azure article, we will discuss the syntax and usage of the New-AzADSpCredential PowerShell command with examples.

New-AzADSpCredential

This Azure PowerShell cmdlet helps you to add a credential to an existing service principal.

Syntax: 

Below is the syntax for the New-AzADSpCredential PowerShell cmdlet.

New-AzADSpCredential
 -ObjectId <String>

Example: 

Let’s consider an example. After executing the below PowerShell command, I got the expected credentials for the service principal with the specified object ID.

New-AzADSpCredential -ObjectId fe1edfc6-19c1-49ca-9be9-6cf073186a42

After executing the above command, I got the below-expected output.

CustomKeyIdentifier DisplayName EndDateTime         Hint KeyId                                SecretText                               StartDateTime   
------------------- ----------- -----------         ---- -----                                ----------                               -------------   
                                01-11-2025 08:01:28 ULL  b98ed9f7-f249-48d0-9cf9-7cb71e25b97f ULL8Q~bBi38~8TRaP0qTPbZJIe3aJIduDwWGabjA 01-11-2023 08...

You can see in the screenshot below that I have executed the above PowerShell command and got the expected output

New-AzADSpCredential

You may also like following the articles below

Conclusion

In this article, we discussed the syntax and usage of the New-AzADSpCredential PowerShell command with examples.