Forum Discussion
Richard_Milner-
Aug 15, 2012Nimbostratus
I'll post the rest of the functions I end up creating in case they will be of use to anyone. This one was a little more interesting as I had to learn what a struct was. It may be worth beefing up the documentation around New-Object -TypeName iControl.LocalLBProfileString; to a non-programmer this stuff isn't very obvious, translating the one example I found from Java to Powershell wasn't simple for me.
I'm also still not clear why I need to insert the LocalLBProfileString into an Array before I can use it?
-------------------------------------------------------------------------
function Create-ClientSSLProfile()
Check whether a ClientSSL Profile exists, create it if required
-------------------------------------------------------------------------
{
Param([string] $profileName);
$ClientSSLArray = @()
$ClientSSLArray = (Get-F5.iControl).LocalLBProfileClientSSL.get_list()
If ($ClientSSLArray -contains $profileName) {
Write-Host "ClientSSL Profile: $profileName already exists" -ForegroundColor Cyan
} Else {
try {
Create LocalLBProfileString Structs for certificate and keys
$defaultCert = New-Object -TypeName iControl.LocalLBProfileString;
$defaultCert.value = "default";
$defaultCert.default_flag = "true";
$defaultCerts = (, $defaultCert);
$defaultKey = New-Object -TypeName iControl.LocalLBProfileString;
$defaultKey.value = "default";
$defaultKey.default_flag = "true";
$defaultKeys = (, $defaultKey);
Create ClientSSL profile
(Get-F5.iControl).LocalLBProfileClientSSL.create( $profileName, $defaultCerts, $defaultKeys )
Write-Host "Created ClientSSL Profile: $profileName" -ForegroundColor Green
} catch {
Write-Host "There was an exception thrown creating ClientSSL Profile: $profileName" -ForegroundColor Red
$Error[0]
}
}
}