fbpx Access User and Machine Certificates | Windows PowerShell, Windows Server | HostingUltraso.com
24/7/365 Support

Access User and Machine Certificates

Problem

You want to retrieve information about certificates for the current user or local machine.

Solution

To browse and retrieve certificates on the local machine, use PowerShell’s certificate drive. This drive is created by the certificate provider, as shown in Example 165.

Example 165. Exploring certificates in the certificate provider

PS >SetLocation cert:\CurrentUser\ PS >$cert = GetChildItem Rec CodeSign PS >$cert | FormatList

Subject : CN=PowerShell User Issuer : CN=PowerShell Local Certificate Root Thumbprint : FD48FAA9281A657DBD089B5A008FAFE61D3B32FD FriendlyName : NotBefore : 4/22/2007 12:32:37 AM NotAfter : 12/31/2039 3:59:59 PM Extensions : {System.Security.Cryptography.Oid, System.Security.Cryptogr

aphy.Oid}

Discussion

The certificate drive provides a useful way to navigate and view certificates for the current user or local machine. For example, if your execution policy requires the use of digital signatures, the following command tells you which publishers are trusted to run scripts on your system:

GetChildItem cert:\CurrentUser\TrustedPublisher

The certificate provider is probably most commonly used to select a codesigning certificate for the SetAuthenticodeSignature cmdlet. The following command selects the “best” code signing certificate—that being the one that expires last:

$certificates = GetChildItem Cert:\CurrentUser\My CodeSign $signingCert = @($certificates | Sort Desc NotAfter)[0] In this CodeSign parameter lets you search for certificates in the certificate store that support code signing.

Although the certificate provider is useful for browsing and retrieving information from the computer’s certificate stores, it does not lets you add or remove items from these locations. If you want to manage certificates in the certificate store, the System.Security.Cryptography.X509Certificates.X509Store class (and other related classes from the System.Security.Cryptography.X509Certificates namespace) from the .NET Framework support that functionality.

For more information about the certificate provider, type GetHelp Certificate.

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 128 GB (SSD SATA) Configure Server
Intel Atom C2750 2.4 GHz 8c/8t 8 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Xeon E3-1230 v2 3.3 GHz 4c/8t 16 GB DDR3 1× 256 GB (SSD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 250 GB (SSD SATA) Configure Server

What Our Clients Say