< Back

Get-X509Certificate

Sat Jan 18, 2020 9:33 pm

NAME Get-X509Certificate



SYNOPSIS

Gets the certificate from web server or file path.





SYNTAX

Get-X509Certificate [-FilePath] <String> [-Confirm] [-WhatIf] [<CommonParameters>]



Get-X509Certificate [-Uri] <String> [[-Port] <Int32>] [-Confirm] [-WhatIf] [<CommonParameters>]





DESCRIPTION

The Get-X509Certificate cmdlet gets the certificate from web server or file path.



To specify a website, use the Uri parameter to specify the url of the resource. If the Port parameter is

specified, the cmdlet will attempt to establish the connection to the specified Uri using the specified port

number.



To specify a file, use the FilePath parameter to specify the file path of the resource.





PARAMETERS

-Confirm [<SwitchParameter>]

Prompts you for confirmation before running the cmdlet.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-FilePath <String>

Specifies the certificate file path.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Port <Int32>

Specifies the port number to establish the connection.



Required? false

Position? 1

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-Uri <String>

Specifies the Uniform Resource Identifier (URI) of the Internet resource to which the web request is sent.

This parameter supports HTTP and HTTPS values.



This parameter is required.



Required? true

Position? 0

Default value None

Accept pipeline input? True (ByPropertyName, ByValue)

Accept wildcard characters? false



-WhatIf [<SwitchParameter>]

Shows what would happen if the cmdlet runs. The cmdlet is not run.



Required? false

Position? named

Default value False

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

System.String





System.Int32







OUTPUTS

System.Security.Cryptography.X509Certificates.X509Certificate2







NOTES





Author : Ryen Kia Zhi Tang



Blog : ryentang.wordpress.com (http://ryentang.wordpress.com/)



Example 1



PS C:\\> Get-X509Certificate -Uri www.msn.com



Thumbprint Subject

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

BFC5351C23FE509832B7496F319F4AD2A8401367 CN=*.msn.com



This command gets the certificate from www.msn.com website domain name.

Example 2



PS C:\\> Get-X509Certificate -Uri https://www.bing.com/search?q=azure



Thumbprint Subject

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

738B62FA6466539F378924C2D47D0934787A6B60 CN=www.bing.com



This command gets the certificate from https://www.bing.com URL.

Example 3



PS C:\\> Get-X509Certificate -Uri proxy.contoso.com -Port 8443



Thumbprint Subject

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

B5B53EF00AE5423DEE73C151A9E0C6F95014A1E1 CN=proxy.contoso.com



This command gets the certificate from proxy.contoso.com domain name on port 8443.

Example 4



PS C:\\> Get-X509Certificate -Uri live.com | Get-X509CertificateChain



Thumbprint Subject

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

454965D4125216F4303529C06292BE8D9B9AA3F8 CN=outlook.live.com

54D9D20239080C32316ED9FF980A48988F4ADF2D CN=Microsoft IT TLS CA 2, OU=Microsoft IT, O=Microsoft Corporation,

L=Redm...

D4DE20D05E66FC53FE1A50882C78DB2852CAE474 CN=Baltimore CyberTrust Root, OU=CyberTrust, O=Baltimore, C=IE



This command gets the certificate from live.com website domain name and pipelined to Get-X509CertificateChain

cmdlet to obtain the certificate chain.

Example 5



PS C:\\> Get-X509Certificate -Uri live.com | Export-Certificate -FilePath live-com.cer



Directory: C:\\



Mode LastWriteTime Length Name

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

-a---- 11/12/17 4:17 PM 1896 live-com.cer



This command gets the certificate from live.com website domain name and save it as certificate file locally by

pipelining to Export-Certificate cmdlet.



RELATED LINKS

X509Certificate2 Class https://docs.microsoft.com/en-gb/dotnet ... ficates.x5

09certificate2?view=netcore-2.0