Update the Remove-IntuneUserPfxCertificate command#127
Open
aendrawos wants to merge 2 commits into
Open
Conversation
It seems that Remove-IntuneUserPfxCertificate -UserThumbprintList <UserThumbprintObjs> is not working. I noticed that <UserThumbprintObjs> should be of value type "Microsoft.Management.Powershell.PFXImport.Cmdlets.UserThumbprint", so if I pass the thumbprint as a string I will get an error. However, even if I create an object with this type and pass to it the UPN and Thumbprint that I want to delete using the below steps, it doesn't work: $Test = New-Object -TypeName Microsoft.Management.Powershell.PFXImport.Cmdlets.UserThumbprint $Test.UserPrincipalName = "<User or UPN>" # << I tried with both User and UPN $Test.Thumbprint = "<Thumbprint_to_delete>" Remove-IntuneUserPfxCertificate -UserThumbprintList $Test # << I get no error, but the certificate is not deleted But I observed that (Get-IntuneUserPfxCertificate -UserThumbprintList $Test) works and display the certificate. I noticed that -CertificateList parameter is not documented, but I managed to get it to work with Remove-IntuneUserPfxCertificate -CertificateList using the following 2 lines of code: $Thumbprint_to_delete = "<Certificate_Thumbprint>" # << replace it by Certificate thumbprint $Certificate_Data = New-Object -TypeName Microsoft.Management.Services.Api.UserPFXCertificate ; $Certificate_Data.Thumbprint = $Thumbprint_to_delete ;$Certificate_Data.UserPrincipalName = (Get-IntuneUserPfxCertificate | where-object thumbprint -eq $Thumbprint_to_delete).userprincipalname ; Remove-IntuneUserPfxCertificate -CertificateList $Certificate_Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It seems that Remove-IntuneUserPfxCertificate -UserThumbprintList is not working. I noticed that should be of value type "Microsoft.Management.Powershell.PFXImport.Cmdlets.UserThumbprint", so if I pass the thumbprint as a string, I will get an error. However, even if I create an object with this type and pass to it the UPN and Thumbprint that I want to delete using the below steps, it doesn't work:
$Test = New-Object -TypeName Microsoft.Management.Powershell.PFXImport.Cmdlets.UserThumbprint
$Test.UserPrincipalName = "" # << I tried with both User and UPN
$Test.Thumbprint = "<Thumbprint_to_delete>"
Remove-IntuneUserPfxCertificate -UserThumbprintList $Test # << I get no error, but the certificate is not deleted
But I observed that (Get-IntuneUserPfxCertificate -UserThumbprintList $Test) works and display the certificate.
I noticed that -CertificateList parameter is not documented, but I managed to get it to work with Remove-IntuneUserPfxCertificate -CertificateList using the following 2 lines of code:
$Thumbprint_to_delete = "<Certificate_Thumbprint>" # << replace it by Certificate thumbprint
$Certificate_Data = New-Object -TypeName Microsoft.Management.Services.Api.UserPFXCertificate ; $Certificate_Data.Thumbprint = $Thumbprint_to_delete ;$Certificate_Data.UserPrincipalName = (Get-IntuneUserPfxCertificate | where-object thumbprint -eq $Thumbprint_to_delete).userprincipalname ; Remove-IntuneUserPfxCertificate -CertificateList $Certificate_Data