Powershell Select-object from cert store Powershell Select-object from cert store powershell powershell

Powershell Select-object from cert store


Don't use format-list, you already have all the properties. format-list will convert your nice X509Certificate2 object into a set of format objects which isn't what you want at all. Also use -expandproperty on the select:

PS>get-childitem | where { $_.subject -eq "CN=localhost" } | select -expandproperty SerialNumber6191F4A438FF77A24763E6D427749CD7

Or with Powershell 3 or later, use the shorthand notation:

PS>$serno = (get-childitem | where { $_.subject -eq "CN=localhost" }).SerialNumberPS>$serno6191F4A438FF77A24763E6D427749CD7