Can I change the default pool for a virt?

Can I make changes to a virt via Powershell? If I have Virt_1 pointing to Pool_1 and I want it to point to Pool_2, can I do that?

Hi kelemvor, you cannot change the BIG-IP configuration using Powershell.

thanks,

Mike

You can actually.

At a minimum you need the following commands:

Add-PSSnapin iControlSnapin
Initialize-F5.iControl -HostName [IP of host name of BIG-IP] -Username [admin username] -Password [admin password]
$changepool = (Get-F5.iControl).LocalLBVirtualServer.set_default_pool_name(("my_vs"), ("my_new_pool"))

Sweet! That worked great.

Thanks!

One other question. Can I work that into a Try/Catch statement?

I tried adding my standard -ea stop -ev error to the end of the get-f5 line but it didn’t seem to like that very much.

Thanks again.

$success = Initialize-F5.iControl -HostName 192.168.1.245 -Username admin -Password password

Try {
   $(Get-F5.iControl).LocalLBVirtualServer.set_default_pool_name(("access-test-vs"), ("local-pool-single1"));
}
Catch {
   Write-Host "Caught an error"
}

Posted By Kevin Stewart on 07/16/2013 03:54 PM

$success = Initialize-F5.iControl -HostName 192.168.1.245 -Username admin -Password password Try { $(Get-F5.iControl).LocalLBVirtualServer.set_default_pool_name(("access-test-vs"), ("local-pool-single1")); } Catch { Write-Host "Caught an error" }

Oh OK. I would always add -ea stop -ev errorvar to the end so the error it finds gets put in the variable and I can then use it to display to the user or log to a file. Does this jsut dump the error to the screen if it finds one or does it not show the actual error at all and just shows what you write-host to the screen?

Not able to test now, but pretty sure this works:

Write-Host $_.Exception.Message