Skip to content

Update the Remove-IntuneUserPfxCertificate command#127

Open
aendrawos wants to merge 2 commits into
microsoft:masterfrom
aendrawos:patch-1
Open

Update the Remove-IntuneUserPfxCertificate command#127
aendrawos wants to merge 2 commits into
microsoft:masterfrom
aendrawos:patch-1

Conversation

@aendrawos
Copy link
Copy Markdown

@aendrawos aendrawos commented Sep 27, 2022

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant