Using powershell commands i want to reset the Service Principal client secret.
I followed the below steps from the article https://learn.microsoft.com/en-us/powershell/azure/create-azure-service-principal-azureps?view=azps-5.8.0 but it didnot reset the password
Remove-AzADSpCredential -DisplayName ServicePrincipalName
$newCredential = New-AzADSpCredential -ServicePrincipalName ServicePrincipalName
can you tell what i am doing wrong. I just want to reset the secret and have new one
I executed the above command and then i went to the app registration of that service principal and there i went to certificates & secrets i see it has not createed new secret.
Using bash i am able to reset the password by executing the below command but i want it to be done using powershell command
az ad sp credential reset --name
Well, actually the command
New-AzADSpCredential
did create a new secret for you. Firstly, you need to know the relationship between App Registration(AD App) and Service principal, see Application and service principal objects in Azure Active Directory.In short, the service principal is the local representation for the AD App in a specific tenant. When you create the secret for the service principal, it will not appear in the
Certificates & secrets
blade, you can just get it withGet-AzADSpCredential
.If you want to reset the secret that you can find in the portal, you need to reset the sceret for the AD App(i.e. App Registration) via
Remove-AzADAppCredential
andNew-AzADAppCredential
.You could refer to the sample below, it resets a secret with value
ce96a0ed-5ae8-4a5a-9b3c-630da9ea3023
, it is valid for one year, you can find it in the portal.Note: You could not get the secret value again after creating it, so please store it when creating.