Forum Discussion
Richard_Milner-
Aug 15, 2012Nimbostratus
Create HTTP Profile function:
-------------------------------------------------------------------------
function Create-HTTPProfile()
Check whether a HTTP Profile exists, create it if required and set its parent profile
We also explicitly turn on the X-FORWARDED-FOR header
-------------------------------------------------------------------------
{
Param([string] $profileName, [string] $parentProfile);
$HTTPProfileArray = @()
$HTTPProfileArray = (Get-F5.iControl).LocalLBProfileHttp.get_list()
If ($HTTPProfileArray -contains $profileName) {
Write-Host "HTTP Profile: $profileName already exists" -ForegroundColor Cyan
} Else {
try {
Create LocalLBProfileMode Structs for the X-FORWARDED-FOR change
$ProfileMode = New-Object -TypeName iControl.LocalLBProfileProfileMode;
$ProfileMode.value = "PROFILE_MODE_ENABLED";
$ProfileModes = (, $ProfileMode);
Create profile
(Get-F5.iControl).LocalLBProfileHttp.create( $profileName )
Set parent profile
(Get-F5.iControl).LocalLBProfileHttp.set_default_profile( $profileName, $parentProfile )
Enable the X-FORWARDED-FOR header
(Get-F5.iControl).LocalLBProfileHttp.set_insert_xforwarded_for_header_mode( $profileName, $ProfileModes )
Write-Host "Created HTTP Profile: $profileName" -ForegroundColor Green
} catch {
Write-Host "There was an exception thrown creating HTTP Profile: $profileName" -ForegroundColor Red
$Error[0]
}
}
}