Scripting: Fetch File SignerPowerShell can retrieve the certificate information from a binary file. From a scripting perspective it is often useful to extract the Common Name (CN) to validate files. However, the default PowerShell output is difficult to parse because the subject fields are in an unpredictable order and may contain quotes etc:
[email protected], CN="Oracle America, Inc.", OU=Software Engineering, O="Oracle America, Inc.", L=Redwood City, S=California, C=US
CN=Microsoft Windows, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and
OU=Engineering, CN="PKWARE, Inc.", L=Brown Deer, S=Wisconsin, C=US, OU=Digital ID Class 3 - Microsoft Software Validation v2, OU="www.verisign.com/repository/RPA Incorp. by Ref.,LIAB.LTD(c)98", OU=VeriSign Commercial Software Publishers CA, O="VeriSign, Inc.", L=Internet There is a simple method to determine the CN using a method which is not widely documented:
Oracle America, Inc. Note this does not seem to work in PowerShell Core. |