< Back

Get-WebCertificate

Mon Jan 13, 2020 8:23 pm

NAME Get-WebCertificate



SYNOPSIS

Makes a web request to an HTTPS website and returns the certificate





SYNTAX

Get-WebCertificate [-FQDN] <String[]> [[-Port] <Int32>] [<CommonParameters>]





DESCRIPTION

Makes an HTTPS web request to a given website and port and returns an X509Certificate2 object.

It will automatically try to connect on TLS1.2, TLS1.1, TLS1.0, SSL3 and SSL2 in that order until it successfully

connects and pulls the certificate





PARAMETERS

-FQDN <String[]>

The fully qualified domain name(s) of the web resource you wish to pull a certificate for.



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Port <Int32>

The TCP/IP port that the resource is running on. This has a default of '443' if not specified.



Required? false

Position? 2

Default value 443

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS>Get-WebCertificate -FQDN google.com



Thumbprint Subject

---------- -------

FD226574BEC85E043AB2007917B9F636171D485C CN=*.google.com, O=Google Inc, L=Mountain View, S=California, C=US









-------------------------- EXAMPLE 2 --------------------------



PS>Get-WebCertificate -FQDN tls-v1-0.badssl.com -Port 1010 -Verbose



VERBOSE: Trying request using TLS1.2

VERBOSE: Error pulling certificate using TLS1.2.

VERBOSE: Trying request using TLS1.1

VERBOSE: Error pulling certificate using TLS1.1.

VERBOSE: Trying request using TLS1.0

VERBOSE: Sucessfully pulled certificate using TLS1.0.



Thumbprint Subject

---------- -------

CA5308746C1E0644D63AF61BF581C72AF90C7095 CN=*.badssl.com, O=Lucas Garron, L=Walnut Creek, S=California, C=US









-------------------------- EXAMPLE 3 --------------------------



PS>$Sites = "google.com","microsoft.com","apple.com"



PS> Get-WebCertificate -FQDN $Sites -Port 443



Thumbprint Subject

---------- -------

FD226574BEC85E043AB2007917B9F636171D485C CN=*.google.com, O=Google Inc, L=Mountain View, S=California, C=US

1E83B66D00F2445EFFA9B2DB51118A46943AA885 CN=*.microsoft.com

768EE9DAE0D8C91E305FBD0DD738CBF1E92DDBF7 CN=www.apple.com, OU=Internet Services, O=Apple Inc., STREET=1 Infinite

Loop, L=Cupertino, S=Ca...









-------------------------- EXAMPLE 4 --------------------------



PS>"google.com","microsoft.com","apple.com" | Get-WebCertificate -Port 443



Thumbprint Subject

---------- -------

FD226574BEC85E043AB2007917B9F636171D485C CN=*.google.com, O=Google Inc, L=Mountain View, S=California, C=US

1E83B66D00F2445EFFA9B2DB51118A46943AA885 CN=*.microsoft.com

768EE9DAE0D8C91E305FBD0DD738CBF1E92DDBF7 CN=www.apple.com, OU=Internet Services, O=Apple Inc., STREET=1 Infinite

Loop, L=Cupertino, S=Ca...











RELATED LINKS