Private/Set-ADCServiceGroupTovServer.ps1

function Set-ADCServiceGroupTovServer {
    <#
.SYNOPSIS
    Sets (Binds) a Service Group to a Load Balancing Virtual Server.
.DESCRIPTION
    Sets (Binds) a Service Group to a Load Balancing Virtual Server.
.PARAMETER Session
    The Citrix ADC Session to execute the function against.
.PARAMETER vServerName
    The Load Balancing Virtual Server Name.
.PARAMETER ServiceGroupName
    The Service Name to bind to the Load Balancing 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
    Set-ADCServiceTovServerGroup -vServerName "vsvr_citrix_storefront_443" -ServiceGroupName "svc_grp_citrix_storefront_443" -Verbose
#>


    [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')]
    Param (
        $Session = $script:session, [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
        [string[]]$vServerName = (Read-Host -Prompt 'Enter Virtual Server Name'),
        [string[]]$ServiceGroupName = (Read-Host -Prompt 'Enter Service Group Name')
    )

    begin {
        $PayLoad = @{
            "name"             = $vServerName
            "servicegroupname" = $ServiceGroupName
        }
    }

    process {
        try {
            if ($Force -or $PSCmdlet.ShouldProcess("ShouldProcess?")) {
                Invoke-ADCRestAPI -Session $Session -Method POST -Type "lbvserver_servicegroup_binding" -Payload $PayLoad -Action Add
                write-verbose "Load Balancing Service Group ($ServiceName) bound to Virtual Server ($vServerName)"
            }
        }
        catch {
            write-verbose "Load Balancing Service Group ($ServiceName) could not be bound to Virtual Server ($vServerName)" 
        }
    }

    end {
    }

}