Skip to content

Add New-EntraServicePrincipalKeyCredential #1487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

DButoyez
Copy link
Collaborator

We've identified an issue with the New-EntraServicePrincipalKeyCredential command in the Entra PowerShell module. While the documentation exists, the command itself does not seem to be implemented.

Here are the details:

Documentation Link: https://github.com/microsoftgraph/entra-powershell/blob/main/module/docs/entra-powershell-v1.0/Applications/New-EntraServicePrincipalKeyCredential.md

Issue: The command New-EntraServicePrincipalKeyCredential is not recognized as a valid cmdlet, function, script file, or executable program in the Entra module version 1.0.5. However, the Get-EntraServicePrincipalKeyCredential command works as expected.

#1453

Copy link

Learn Build status updates of commit c906d57:

✅ Validation status: passed

File Status Preview URL Details
module/Entra/Microsoft.Entra/Applications/New-EntraServicePrincipalKeyCredential.ps1 ✅Succeeded
module/EntraBeta/Microsoft.Entra.Beta/Applications/New-EntraBetaServicePrincipalKeyCredential.ps1 ✅Succeeded

For more details, please refer to the build report.

Copy link

Learn Build status updates of commit 37be4b6:

✅ Validation status: passed

File Status Preview URL Details
module/Entra/Microsoft.Entra/Applications/New-EntraServicePrincipalKeyCredential.ps1 ✅Succeeded
module/EntraBeta/Microsoft.Entra.Beta/Applications/New-EntraBetaServicePrincipalKeyCredential.ps1 ✅Succeeded
test/Entra/Applications/New-EntraServicePrincipalKeyCredential.Tests.ps1 ✅Succeeded

For more details, please refer to the build report.

Copy link

Learn Build status updates of commit f8e26c2:

❌ Validation status: errors

Please follow instructions here which may help to resolve issue.

File Status Preview URL Details
❌Error Details

  • Line 0, Column 0: [Error: download-failed] Download failed for file 'https://opdhsblobprod03.blob.core.windows.net/contents/0e7c70ab16fb40c99c4377c036d9bd97/0536b2b7bad9fa49538eb4ecb40abdf9'. Try closing and reopening the PR. If you get this Error again, file an issue.

For more details, please refer to the build report.

Note: Your PR may contain errors or warnings or suggestions unrelated to the files you changed. This happens when external dependencies like GitHub alias, Microsoft alias, cross repo links are updated. Please use these instructions to resolve them.

Copy link

@DButoyez DButoyez marked this pull request as ready for review June 13, 2025 06:30
@DButoyez DButoyez requested a review from a team as a code owner June 13, 2025 06:30
Copy link

@DButoyez DButoyez added the Ready For Review The PR Ready for Review label Jun 16, 2025
Write-Error -Message $errorMessage -ErrorAction Stop
}
$params["PasswordCredential"] = @{
secretText = $PSBoundParameters["CustomKeyIdentifier"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not too sure if we should support this here coz there's another command for adding password credential https://learn.microsoft.com/en-us/powershell/module/microsoft.entra/new-entraapplicationpasswordcredential?view=entra-powershell

Derrick Butoyi added 2 commits June 18, 2025 08:38
Copy link

[System.String]$Proof,

[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, HelpMessage = "Contain the password for the key. This property is required for keys of type X509CertAndPassword.")]
[System.String]$PasswordCredential,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This param is not needed.
Check the mapping below
image

New-EntraServicePrincipalKeyCredential should map to New-AzureADServicePrincipalKeyCredential.

Below are the params for New-AzureADServicePrincipalKeyCredential
https://github.com/Azure/azure-docs-powershell-azuread/blob/main/azureadps-2.0/AzureAD/New-AzureADServicePrincipalKeyCredential.md#syntax

[System.String]$Usage,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, HelpMessage = "A self-signed JWT token used as a proof of possession of the existing keys. This JWT token must be signed with a private key that corresponds to one of the existing valid certificates associated with the servicePrincipal.")]
[System.String]$Proof,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This param is not needed

[System.String]$Value,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, HelpMessage = "Specifies the type of key credential (e.g., AsymmetricX509Cert, Symmetric).")]
[ValidateSet('AsymmetricX509Cert', 'X509CertAndPassword')]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -> https://learn.microsoft.com/en-us/graph/api/serviceprincipal-addkey?view=graph-rest-1.0&tabs=http

Supported key types are:
AsymmetricX509Cert: The usage must be Verify.
X509CertAndPassword: The usage must be Sign

[System.String]$Type,

[Parameter(Mandatory = $true, ValueFromPipeline = $true, HelpMessage = "Specifies the usage of the key credential (e.g., Sign, Verify).")]
[ValidateSet('Sign', 'Verify')]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the only set?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review The PR Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants