Forum Discussion

Sudesh_tendulka's avatar
Sudesh_tendulka
Icon for Nimbostratus rankNimbostratus
Oct 31, 2013

How to set iControl.LocalLBCookiePersistenceMethod using Powershell?

Hi I am trying to create persistence profile with the following parameters, Using Powershell

 

Method: Insert SessionCookie: False ExpirationMinutes: 60

 

After going through the API details, I found the class iControl.LocalLBCookiePersistenceMethod I am using following code to set the value, However its giving error "Property 'value' cannot be found on this object; make sure it exists and is settable." for the code highlighted in bold. Can anybody tell me whether I have selected correct class and how can we set the Cookie method to Insert?

 

{ Param( [string] $profileName ); $profiles = (, $profileName); $PersistanceArray = @() $PersistanceArray = (Get-F5.iControl).LocalLBProfilePersistence.get_list() If ($PersistanceArray -contains $profileName) { Write-Host "Persistance Profile: $profileName already exists" -ForegroundColor Cyan $res = @() $res=(Get-F5.iControl).LocalLBProfilePersistence.get_default_profile($profileName); foreach ($i in $res) {Write-Host $i.value}

 

} Else {
try {

 $mode = New-Object -TypeName iControl.LocalLBPersistenceMode;
 $mode ="PERSISTENCE_MODE_COOKIE";
 $modes=(,$mode)

(Get-F5.iControl).LocalLBProfilePersistence.create($profiles,$modes);   
Write-Host "Persistance Profile: $profiles created";

$method1 = New-Object -TypeName iControl.LocalLBCookiePersistenceMethod;$method1.value =1;"COOKIE_PERSISTENCE_METHOD_INSERT"; $methods=(,$method1);(Get-F5.iControl).LocalLBProfilePersistence.set_cookie_persistence_method($profiles,$methods);

 

$cookieName = New-Object -TypeName iControl.LocalLBProfileString;
$cookieName.value = "cookie-Xy";
$cookieName.default_flag = "false";
$cookieNames = (, $cookieName);
(Get-F5.iControl).LocalLBProfilePersistence.set_cookie_name($profiles,$cookieNames);

$time = New-Object -TypeName iControl.LocalLBProfileULong;
$time.value=600;
$time.default_flag = "false";
$times=(,$time);    

(Get-F5.iControl).LocalLBProfilePersistence.set_cookie_expiration($profiles,$times);


} catch {
  Write-Host "There was an exception thrown creating Persistance Profile: $profileName" -ForegroundColor Red
  $Error[0]
}

} }

 

1 Reply

  • Figured it out we need to use iControl.LocalLBProfileCookiePersistenceMethod instead of iControl.LocalLBCookiePersistenceMethod So the correct statement should be $method1 = New-Object -TypeName iControl.LocalLBProfileCookiePersistenceMethod