Skip to content

Commit

Permalink
Merge pull request #34 from AutomatedLab/develop
Browse files Browse the repository at this point in the history
Latest changes on CA functions
  • Loading branch information
raandree committed Aug 24, 2018
2 parents 363a099 + 46617cf commit 052c3c3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 3 additions & 4 deletions AutomatedLab.Common/NetworkHelper/Public/Test-Port.ps1
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
function Test-Port
{
[cmdletbinding()]

[Cmdletbinding()]
Param(
[Parameter(Mandatory, Position = 0)]
[Parameter(Mandatory, Position = 0, ValueFromPipeline, ValueFromPipelineByPropertyName)]
[string[]]$ComputerName,

[Parameter(Mandatory, Position = 1)]
[Parameter(Mandatory, Position = 1, ValueFromPipelineByPropertyName)]
[int]$Port,

[int]$Count = 1,
Expand Down
14 changes: 8 additions & 6 deletions AutomatedLab.Common/PkiHelper/Public/Publish-CaTemplate.ps1
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
function Publish-CATemplate
function Publish-CaTemplate
{
[cmdletBinding()]
param(
[Parameter(Mandatory = $true)]
[string]$TemplateName
)

$caInfo = certutil.exe -CAInfo
$ca = Find-CertificateAuthority
$caInfo = certutil.exe -CAInfo -Config $ca
if ($caInfo -like '*No local Certification Authority*')
{
Write-Error 'This command needs to run on a CA'
Write-Error 'No issuing CA found in the machines domain'
return
}
$computerName = $ca.Split('\')[0]

$start = Get-Date
$done = $false
$i = 0
do
{
Write-Verbose -Message "Trying to publish '$TemplateName' at ($(Get-Date)), retry count $i"
$result = certutil.exe -SetCAtemplates "+$TemplateName" | Out-Null
Write-Verbose -Message "Trying to publish '$TemplateName' on '$ca' at ($(Get-Date)), retry count $i"
certutil.exe -Config $ca -SetCAtemplates "+$TemplateName" | Out-Null
if (-not $LASTEXITCODE)
{
$done = $true
Expand All @@ -28,7 +30,7 @@ function Publish-CATemplate
{
if ($i % 5 -eq 0)
{
Restart-Service -Name CertSvc
Get-Service -Name CertSvc -ComputerName $computerName | Restart-Service
}

$ex = New-Object System.ComponentModel.Win32Exception($LASTEXITCODE)
Expand Down

0 comments on commit 052c3c3

Please sign in to comment.