After taking a fresh look today, it appears to be a syntax error that caused the iControl interface to throw an exception the lead me down the wrong path. This works now :-)
Set Source Address Affinity - so called "sticky session"
$Persistence = New-Object -TypeName iControl.LocalLBVirtualServerVirtualServerPersistence;
$Persistence.profile_name = 'source_addr'
$Persistence.default_profile = $true
$Pers_ProfileA = (, $Persistence);
$Pers_ProfileAofA = (, $Pers_ProfileA);
Write-Host "Enabling Source Address Affinity on Virtual Server `"$name`"...";
Try {
(Get-F5.iControl).LocalLBVirtualServer.add_persistence_profile($name, $Pers_ProfileAofA)
}
Catch {
Write-Host "Error - Adding Persistence Profile! - Exception - $_.exception" -ForegroundColor Red
Write-Host "Message - $_.exception.message" -ForegroundColor Red
Write-Host "Deleting VS: $name"
(Get-F5.iControl).LocalLBVirtualServer.delete_virtual_server(($name))
}
}
Else
{
Write-Host "Error - VS Name Already Exists - $name"
}