Now, with the certificate provider, you cannot do much,
as we have a dedicated PKI module to work with certificates; however,
there are still some tasks that you can perform using general commands.
You can list certificate stores and certificates using
Get‑Item and Get‑ChildItem commands, and remove them using Remove‑Item command.
We will now quickly switch to our demo environment.
In this demo, we will list certificates from a certificate store.
Next, we will delete certificates using Remove‑Item command.
We will start by having a look into certificate snap‑in.
This is the user certificate snap‑in.
In here, we can see different certificate stores that have certificates in it.
This is the user's personal store that has one certificate in it.
When I click on Trusted Root CA store,
we can see all the trusted root CA certificates.
We will now switch to PowerShell and see how we can
navigate into these certificate stores.
I'll enter Set‑Location, command, and mention cert PS drive.
I'll run Get‑Item * command,
and we can see that there are two certificate stored locations,
CurrentUser stores, user certificates,
and LocalMachine stores system certificates.
I will navigate into CurrentUser certificate store,
and again run Get‑Item * command.
Here,
we can see a list of all certificate stores that we saw a
moment ago from certificate snap‑in.
The My certificate store in PowerShell refers to the user's personal store,
and Root certificate store in PowerShell refers to the
trusted root certification authority store.
I'll retrieve all root certificates using Get‑ChildItem command,
and mention Root certificate store.
If I want to retrieve only a specific certificate,
I can do so by entering its thumbprint.
And just to see what all properties we have for a certificate,
I'll pipe this command to select *.
Here we can see a number of properties,
which we can use as a criteria to filter our search results.
If I want to fetch a list of all certificates that will expire in 30 days,
I can do so by mentioning ExpiringInDays parameter,
and set it to 30 days.
I'll then add Recurse parameter so that the search will
be performed on all child containers.
Next, I'll select a few of its properties like thumbprint,
subject, and ExpiryDate,
and display the result in list format using Format‑List command.
This will also list certificates that are already expired.
If you remember in the first module, we talked about CodeSigningCert parameter.
We can use it to review certificates that have CodeSigning authority,
but as of now, I don't have any CodeSigningCertificates in my system,
so the result will be blank.
To remove a certificate, I'll simply use Remove‑Item command,
followed by a complete path of the certificate.
I'll use any of the expired certificates for this demo,
and enter its thumbprint.
When I run the command, the certificate will be removed.
We will cross verify this, but again running the previous command,
and now we can see that the certificate, which we removed, is not showing up here.