summaryrefslogtreecommitdiffstats
path: root/dist/Scripts/ImportKemp.ps1
blob: c961b212ff2adb7af068009226d3763e112e8f4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<#
.SYNOPSIS
Imports a cert from WASC renewal into KEMP Loadmaster.
.DESCRIPTION
Note that this script is intended to be run via the install script plugin from WASC via the batch script wrapper. As such, we use positional parameters to avoid issues with using a dash in the cmd line. 

THIS SCRIPT IS INCOMPLETE AND *mostly* UNTESTED (some modifications have come in from people using it successfully)
Proper information should be available here

https://github.com/PKISharp/win-acme/wiki/Install-Script

or more generally, here

https://github.com/PKISharp/win-acme/wiki/Example-Scripts

.PARAMETER CertName
The exact ID of the cert to be imported.

.PARAMETER PfxFile
File name in the CertificatePath.

.PARAMETER PfxPassword
(Central Certificate Store) Password of the .pfx file.

.PARAMETER KempUserName
Username for KEMP PowerShell module

.PARAMETER KempUserPass
Password for KEMP PowerShell module

.PARAMETER KempIP
KEMP IP address

.EXAMPLE 

./Scripts/ImportKemp.ps1 "'{RenewalId}' '{CacheFile}' '{CachePassword}' 'bal' 'pass' '10.10.10.10'"


.NOTES
KEMP PowerShell module installation help:
https://support.kemptechnologies.com/hc/en-us/articles/203863385-PowerShell#MadCap_TOC_8_2

Download site, Tools --> General --> LoadMaster PowerShell API Wrapper: https://kemptechnologies.com/loadmaster-documentation/

#>

param(
	[Parameter(Position=0,Mandatory=$true)]
	[string]
	$CertName,
		
	[Parameter(Position=1,Mandatory=$false)]
	[string]
	$PfxFile,
	
	[Parameter(Position=2,Mandatory=$false)]
	[string]
	$PfxPassword,
	
	[Parameter(Position=3,Mandatory=$false)]
	[string]
	$KempUserName,

	[Parameter(Position=4,Mandatory=$false)]
	[string]
	$KempUserPass,

    [Parameter(Position=5,Mandatory=$false)]
	[string]
	$KempIP
)

Import-Module Kemp.LoadBalancer.Powershell

#Get-Module Kemp.LoadBalancer.Powershell
#Test-LmServerConnection -ComputerName $KempIP -Port 443 -Verbose

$password = ConvertTo-SecureString $KempUserPass -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential -ArgumentList ($KempUserName, $password)
$arrLMConnectResult = Initialize-LmConnectionParameters -Address $KempIP -LBPort 443 -Credential $psCred

#Get-Command -Module Kemp.LoadBalancer.Powershell | Out-GridView
#(Get-TlsCertificate).Data.cert

$NewTlsCertificateResult = New-TlsCertificate -Name $CertName -Password $PfxPassword -Replace -Path $PfxFile
if($NewTlsCertificateResult.returncode -eq "422"){
    $NewTlsCertificateResult = New-TlsCertificate -Name $CertName -Password $PfxPassword -Path $PfxFile
}

$NewTlsCertificateResult