Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, September 15, 2016 5:03 PM
Hello,
I am trying to create a script that will filter all certs in LocalMachine\My store by Certificate Template and delete the one I want.
This is proving harder than I thought:
$temp = Get-ChildItem Cert:\LocalMachine\My |
% {
$_ | Select `
Friendlyname,
Thumbprint,
@{N="Template";E={($_.Extensions |
?{$_.oid.Friendlyname -match "Certificate Template Information"}).Format(0).trimstart("Template=").trimend(", Major Version Number=100, Minor Version Number=1" ) #`
}}}
I can get the certificate OID to show by with a lot of garbage but I cant find a command to delete it ...
M
Maelito
All replies (6)
Thursday, September 15, 2016 5:08 PM
Just use Remove-Item
\(ツ)_/
Thursday, September 15, 2016 5:12 PM
Try this:
Get-ChildItem Cert:\LocalMachine\My |
?{ $_.Extensions.oid.Friendlyname -match 'Certificate Template Information' } |
Remove-Item -WhatIf
\(ツ)_/
Friday, September 16, 2016 3:28 AM | 2 votes
Hi Maelito,
>>I am trying to create a script that will filter all certs in LocalMachine\My store by Certificate Template and delete the one I want.
Please refer to links below, I suppose they will provide some guides:
Get-ChildItem -Path cert:\LocalMachine -DnsName *Fabrikam* | Remove-Item
https://technet.microsoft.com/en-us/library/hh847855.aspx
If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.
If no, please reply and tell us the current situation in order to provide further help.
Best regards,
Andy_Pan
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
If you have feedback for TechNet Subscriber Support, contact [email protected].
Friday, September 16, 2016 11:07 AM
Hi
Let me try to explain what I am looking for:
Pls see attached picture - the field "Certificate Template Information" contains the long number.
I need to delete all certs with that number as this specific cert does not have Friendly Name, and the ThumbPrint would be different on all machines. So the only common ID is the big long number.
From my investigation I think this is encapsulated in the Extensions Property - but I dont see how I can filter this to the specific value (1.2.3.1.2.3).
To get these I used:
Get-ChildItem "Cert:\LocalMachine\My" | Get-Member
Maelito
Friday, September 16, 2016 11:09 AM
Please see my reply - Thanks for your suggestion but I don't want to delete all certs with DNSName = "Domain.com" but I targeting a specific Cert...
M
Maelito
Friday, September 23, 2016 1:15 PM
Get-ChildItem Cert:\LocalMachine\My |
Where { $_.Extensions.Format(1) -like '*1.3.6.1.4.1.xxxxxxxxxxxxxx*' }