Private/Add-ADCLoadBalancingvServer.ps1

function Add-ADCLoadBalancingvServer {
    <#
.SYNOPSIS
    Adds a Load Balancing vServer Server to the Citrix ADC.
.DESCRIPTION
    Adds a Load Balancing vServer Server to the Citrix ADC.
.PARAMETER Session
    The Citrix ADC Session to execute the function against.
.PARAMETER vServerName
    The Virtual Server Name.
.PARAMETER vServerType
    The Virtual Server Type.
.PARAMETER vServerIPv4
    The IP Address for the Virtual Server
.PARAMETER vServerPort
    The port for the Virtual Server
.NOTES
    Creation Date: 20/06/2018
.CHANGE CONTROL
    Name Version Date Change Detail
    David Brett 1.0 29/03/2018 Function Creation
.EXAMPLE
    Add-ADCLoadBalancingvServer -vServerName "vsvr_storefront_443" -vServerType "SSL" -vServerIPv4 "192.168.0.11" -vServerPort 443 -Verbose
#>


    [CmdletBinding()]
    Param (
        $Session = $script:session,
        [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
        [string[]]$vServerName = (Read-Host -Prompt 'Enter Virtual Server Name'),
        [string[]]$vServerType = (Read-Host -Prompt 'Enter Virtual Server Type'),
        [string[]]$vServerIPv4 = (Read-Host -Prompt 'Enter Virtual Server IPv4 Address'),
        [int[]]$vServerPort = (Read-Host -Prompt 'Enter Virtual Server Port'),
        [string[]]$Persistence = "SOURCEIP",
        [string[]]$LoadBalancingMethod = "LEASTRESPONSETIME"
    )

    begin {
        $PayLoad = @{
            name        = "$vServerName"
            servicetype = "$vServerType"
            ipv46       = "$vServerIPv4"
            port        = "$vServerPort"
            persistencetype = "$Persistence"
            lbmethod = "$LoadBalancingMethod"
        }
    }

    process {
        try {
            Invoke-ADCRestAPI -Session $Session -Method POST -Type "lbvserver" -Payload $PayLoad -Action Add
            write-verbose "Load Balancing vServer ($vServerName) added to the Citrix ADC of type ($vServerType) on IP Address ($vServerIPv4) on port ($vServerPort)"
        }
        catch {
            write-verbose "Load Balancing vServer ($vServerName) could not be added to the Citrix ADC of type ($vServerType) on IP Address ($vServerIPv4) on port ($vServerPort)"
        }
    }

    end {
    }
    
}