fbpx Program: Search the Certificate Store | Windows PowerShell, Windows Server | HostingUltraso.com
24/7/365 Support

Program: Search the Certificate Store

Discussion

One useful feature of the certificate provider is that it provides a –CodeSign parameter that lets you search for certificates in the certificate store that support code signing. Code signing certificates are not the only kind of certificates, however; other frequently used certificate types are Encrypting File System, Client Authentication, and more.

Example 166 lets you search the certificate provider for certificates that support a given Enhanced Key Usage (EKU).

Example 166. SearchCertificateStore.ps1

############################################################################## ## ## SearchCertificateStore.ps1 ## ## Search the certificate provider for certificates that match the specified ## Enhanced Key Usage (EKU.) ## ## ie: ## ## PS >SearchCertificateStore "Encrypting File System" ## ##############################################################################

param( $ekuName = $(throw "Please specify the friendly name of an " + "Enhanced Key Usage (such as 'Code Signing'") )

Example 166. SearchCertificateStore.ps1 (continued)

## Go through every certificate in the current user's "My" store foreach($cert in GetChildItem cert:\CurrentUser\My) {

## For each of those, go through its extensions foreach($extension in $cert.Extensions) {

## For each extension, go through its Enhanced Key Usages foreach($certEku in $extension.EnhancedKeyUsages) {

## If the friendly name matches, output that certificate if($certEku.FriendlyName eq $ekuName) {

$cert } } } }

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

What Our Clients Say