PoshCode Archive  Artifact [e5e3ce62e1]

Artifact e5e3ce62e101aa4800927aedf851169eb1b41553ef74dd52e0e98447cbf95249:

  • File Get-CertificationAuthori.ps1 — part of check-in [410b67f2df] at 2018-06-10 12:56:59 on branch trunk — Retrieves all Enterprise Certification Authorities (CA) in cuurent AD forest (user: Vadims Podans size: 1338)

# encoding: ascii
# api: powershell
# title: Get-CertificationAuthori
# description: Retrieves all Enterprise Certification Authorities (CA) in cuurent AD forest
# version: 1.0
# type: function
# author: Vadims Podans
# license: CC0
# function: Get-CertificationAuthority
# x-poshcode-id: 1394
# x-archived: 2015-11-12T23:51:17
# x-published: 2009-10-14T00:44:00
#
#
#####################################################################
# Get-CertificationAuthority.ps1
# Version 1.0
#
# Retrieves all Enterprise Certification Authorities in cuurent AD forest
#
# Vadims Podans (c) 2009
# http://www.sysadmins.lv/
####################################################################

function Get-CertificationAuthority ([string]$CAName) {
	$domain = ([System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()).Name
	$domain = "DC=" + $domain -replace '\.', ", DC="
	$CA = [ADSI]"LDAP://CN=Enrollment Services, CN=Public Key Services, CN=Services, CN=Configuration, $domain"
	$CAs = $CA.psBase.Children | %{
		$current = "" | Select CAName, Computer
		$current.CAName = $_ | %{$_.Name}
		$current.Computer = $_ | %{$_.DNSHostName}
		$current
	}
	if ($CAName) {$CAs = @($CAs | ?{$_.CAName -eq $CAName})}
	if ($CAs.Count -eq 0) {throw "Sorry, here is no CA that match your search"}
	$CAs
}