Private/Add-ADCServiceGroupMember.ps1

function Add-ADCServiceGroupMember {
    <#
.SYNOPSIS
    Adds a member to a Service Group.
.DESCRIPTION
    Adds a member to a Service Group.
.PARAMETER Session
    The Citrix ADC Session to execute the function against.
.PARAMETER ServiceGroupName
    The Service Group Name.
.PARAMETER ServerName
    The Server Name.
.PARAMETER Port
    The Port to use.
.NOTES
    Creation Date: 20/06/2018
.CHANGE CONTROL
    Name Version Date Change Detail
    David Brett 1.0 29/03/2018 Function Creation
.EXAMPLE
    Add-ADCServiceGroupMember -ServiceGroupName "svc_grp_citrix_storefront_443" -ServerName "web01.bretty.me.uk" -Port 443 -Verbose
#>


    [CmdletBinding()]
    Param (
        $Session = $script:session,
        [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
        [string[]]$ServiceGroupName = (Read-Host -Prompt 'Enter Service Group Name'),
        [string[]]$ServerName = (Read-Host -Prompt 'Enter Server Name'),
        [int[]]$ServiceGroupPort = (Read-Host -Prompt 'Enter Port')
    )

    begin {
        $PayLoad = @{
            "servicegroupname" = "$ServiceGroupName"
            "port"             = "$ServiceGroupPort"
            "servername"       = "$ServerName"
        }
    }

    process {
        try {
        Invoke-ADCRestAPI -Session $Session -Method PUT -Type "servicegroup_servicegroupmember_binding" -Payload $PayLoad
        write-verbose "Server ($ServerName) added to Service Group ($ServiceGroupName) on Port ($Port)"
        }
        catch {
            write-verbose "Server ($ServerName) could not be added to Service Group ($ServiceGroupName) on Port ($Port)" 
        }
    }

    end {
    }
    
}