PoshCode Logo PowerShell Code Repository

Difference between
modified post 6802 by tarique on Fri 17th Mar 04:50 and
original post 2521 by Andy Arismendi on Thu 24th Feb 18:15
Showold version | new version | both versions

    
1-
function Get-WebsiteCertificate {
1+
<#
2-
	[CmdletBinding()]
2+
	.NOTES
3-
	param (
3+
	===========================================================================
4-
		[Parameter(Mandatory=$true)] [System.Uri]
4+
	 Created with: 	SAPIEN Technologies, Inc., PowerShell Studio 2014 v4.1.57
5-
			$Uri,
5+
	 Created on:   	11/3/2014 6:45 AM
6-
		[Parameter()] [System.IO.FileInfo]
6+
	 Created by:   	Brian
7-
			$OutputFile,
7+
	 Organization:
8-
		[Parameter()] [Switch]
8+
	 Filename:
9-
			$UseSystemProxy,
9+
	===========================================================================
10-
		[Parameter()] [Switch]
10+
	.DESCRIPTION
11-
			$UseDefaultCredentials,
11+
		A description of the file.
12-
		[Parameter()] [Switch]
12+
#>
13-
			$TrustAllCertificates
13+
$vcacapfqdn = $args[0]
14-
	)
15-
	try {
16-
		$request = [System.Net.WebRequest]::Create($Uri)
17-
		if ($UseSystemProxy) {
18-
			$request.Proxy = [System.Net.WebRequest]::DefaultWebProxy
19-
		}
21-
		if ($UseSystemProxy -and $UseDefaultCredentials) {
15+
function Get-WebsiteCertificate {
22-
			$request.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
16+
	#By: Andy Arismendi
23-
		}
17+
	#http://poshcode.org/2521
18+
	[CmdletBinding()]
25-
		if ($TrustAllCertificates) {
19+
	param (
26-
			# Create a compilation environment
20+
		[Parameter(Mandatory = $true)] [System.Uri]
27-
			$Provider=New-Object Microsoft.CSharp.CSharpCodeProvider
21+
		$Uri,
28-
			$Compiler=$Provider.CreateCompiler()
22+
		[Parameter()] [System.IO.FileInfo]
29-
			$Params=New-Object System.CodeDom.Compiler.CompilerParameters
23+
		$OutputFile,
30-
			$Params.GenerateExecutable=$False
24+
		[Parameter()] [Switch]
31-
			$Params.GenerateInMemory=$True
25+
		$UseSystemProxy,
32-
			$Params.IncludeDebugInformation=$False
26+
		[Parameter()] [Switch]
33-
			$Params.ReferencedAssemblies.Add("System.DLL") > $null
27+
		$UseDefaultCredentials,
34-
			$TASource=@'
28+
		[Parameter()] [Switch]
35-
			  namespace Local.ToolkitExtensions.Net.CertificatePolicy {
29+
		$TrustAllCertificates
36-
			    public class TrustAll : System.Net.ICertificatePolicy {
30+
	)
37-
			      public TrustAll() {
31+
	try
32+
	{
33+
		$request = [System.Net.WebRequest]::Create($Uri)
34+
		if ($UseSystemProxy)
35+
		{
36+
			$request.Proxy = [System.Net.WebRequest]::DefaultWebProxy
3837
			      }
39-
			      public bool CheckValidationResult(System.Net.ServicePoint sp,
40-
			        System.Security.Cryptography.X509Certificates.X509Certificate cert,
39+
		if ($UseSystemProxy -and $UseDefaultCredentials)
41-
			        System.Net.WebRequest req, int problem) {
40+
		{
42-
			        return true;
41+
			$request.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
4342
			      }
44+
		if ($TrustAllCertificates)
45+
		{
46+
			# Create a compilation environment
47+
			$Provider = New-Object Microsoft.CSharp.CSharpCodeProvider

ContributeMost Recent Contributions (feed)

Contribute ... Next Page