Find certificate using PowerShell 2.0

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Find certificate using PowerShell 2.0

Post by Nemesis808 »

HI All!

I'm in the process of learning PowerShell and had a question. I'm trying to find a certificate from a specific issuer in the local computer personal store. Anyone have any ideas or have a previously written script for something like this written in PowerShell 2.0?



S
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Find certificate using PowerShell 2.0

Post by jvierra »

Get-Content cert:CurrentUser\My | select issuer,subject
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Re: Find certificate using PowerShell 2.0

Post by Nemesis808 »

jvierra wrote:Get-Content cert:CurrentUser\My | select issuer,subject

When I run the above I get the following error message

Get-Content : Cannot use interface. The IContentCmdletProvider interface is not implemented by this provider.
At C:\Users\XXXXX\Documents\SAPIEN\PowerShell Studio\Files\Detect_Certificate.ps1:13 char:1
+ Get-Content cert:CurrentUser\My | select issuer, corp-XXXXXXX-CA
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Get-Content], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.GetContentCommand
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Re: Find certificate using PowerShell 2.0

Post by Nemesis808 »

jvierra wrote:Get-Content cert:CurrentUser\My | select issuer,subject

With Powershell 2.0 shouldn't I be using "System.Security.Cryptography.X509Certificates" ?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Find certificate using PowerShell 2.0

Post by jvierra »

If your 2.0 does not have the cert provider??? Yes. Try the example first. The CERT provider is available on all current versions of PowerShell. PS 2 is current on WS2008R2.
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Re: Find certificate using PowerShell 2.0

Post by Nemesis808 »

jvierra wrote:If your 2.0 does not have the cert provider??? Yes. Try the example first. The CERT provider is available on all current versions of PowerShell. PS 2 is current on WS2008R2.

All of our systems are running PS 2.0... what should I do?
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Find certificate using PowerShell 2.0

Post by jvierra »

Try the code I posted.
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Re: Find certificate using PowerShell 2.0

Post by Nemesis808 »

jvierra wrote:Try the code I posted.

When i do i get this.....

Get-Content : Cannot use interface. The IContentCmdletProvider interface is not implemented by this provider.
At line:1 char:1
+ Get-Content cert:CurrentUser\My | select issuer,subject
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:) [Get-Content], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.GetContentCommand


Am i missing something???
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Find certificate using PowerShell 2.0

Post by jvierra »

Get-ChildItem cert:

Sorry. I typoed. It should read:

Get-ChildItem cert:\CurrentUser\My | select issuer,subject
User avatar
Nemesis808
Posts: 6
Last visit: Thu Dec 14, 2023 2:46 pm

Re: Find certificate using PowerShell 2.0

Post by Nemesis808 »

jvierra wrote:Get-ChildItem cert:

Sorry. I typoed. It should read:

Get-ChildItem cert:\CurrentUser\My | select issuer,subject
It's working! Thanks jvierra
This topic is 6 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked