PowerShell: Create Virtual Server
Add-PSSnapIn iControlSnapIn
$creds = get-credential
$username = ($creds.username).replace("\","")
$password = $creds.GetNetworkCredential().password
Initialize-F5.iControl -Hostname 1.1.1.1 -Username $username -Password $password
$IC = Get-F5.iControl
CODE TO CREATE VIP
$VirtualDefinition = $null
$WildMask = $null
$Resources = $null
$Profile = $null
$Profile_Array = $null
$VirtualDefinition = New-Object icontrol.CommonVirtualServerDefinition
$VirtualDefinition.address = "10.10.10.50"
$VirtualDefinition.name = "TestVirtual"
$VirtualDefinition.port = 80
$VirtualDefinition.protocol = "PROTOCOL_TCP"
$WildMask = "255.255.255.255"
$Resources = New-Object iControl.LocalLBVirtualServerVirtualServerResource
$Resources.default_pool_name = ""
$Resources.type = "RESOURCE_TYPE_POOL"
$Profile = New-Object iControl.LocalLBVirtualServerVirtualServerProfile
$Profile.profile_name = "Blank"
$Profile.profile_context = "PROFILE_CONTEXT_TYPE_ALL"
$Profile_Array = new-object "iControl.LocalLBVirtualServerVirtualServerProfile[][]" 1,1
$Profile_Array[0][0] = $Profile
$ic.LocalLBVirtualServer.create($VirtualDefinition, $WildMask, $Resources, $Profile)
... here is the error:
Exception calling "create" with "4" argument(s): "Exception caught in LocalLB::urn:iControl:LocalLB/VirtualServer::create()
Exception: Common::OperationFailed
primary_error_code : 16908342 (0x01020036)
secondary_error_code : 0
error_string : 01020036:3: The requested profile () was not found."
At U:\Powershell\(TESTING)F5-Scripting.ps1:33 char:32
+ $ic.LocalLBVirtualServer.create <<<< ($VirtualDefinition, $WildMask, $Resources, $Profile)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
... I'd like to be able to create one with no HTTP Profile at all, if possible. Thanks in advance for any assistance. I can't find a lot of good documentation on how to use PowerShell to manipulate iControl and even less on creating Virtual Servers.