Private/Add-ADCServiceGroup.ps1

function Add-ADCServiceGroup {
    <#
.SYNOPSIS
    Adds a Load Balancing ServiceGroup to the Citrix ADC.
.DESCRIPTION
    Adds a Load Balancing ServiceGroup to the Citrix ADC.
.PARAMETER Session
    The Citrix ADC Session to execute the function against.
.PARAMETER ServiceGroupName
    The Service Name.
.PARAMETER ServiceGroupType
    The Service Type.
.PARAMETER StoreFront
    Switch to define if the service group being added is for StoreFront.
.NOTES
    Creation Date: 20/06/2018
.CHANGE CONTROL
    Name Version Date Change Detail
    David Brett 1.0 29/03/2018 Function Creation
.EXAMPLE
    Add-ADCServiceGroup -ServiceGroupName "svc_grp_citrix_storefront_443" -ServiceGroupType "SSL" -Verbose
#>


    [CmdletBinding()]
    Param (
        $Session = $script:session,
        [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
        [string[]]$ServiceGroupName = (Read-Host -Prompt 'Enter Service Group Name'),
        [string[]]$ServiceGroupType = (Read-Host -Prompt 'Enter Service Group Type'),
        [Parameter(ValueFromPipeline)][switch]$StoreFront
    )

    begin {
        if ($StoreFront) {
            $PayLoad = @{
                servicegroupname = "$ServiceGroupName"
                servicetype      = "$ServiceGroupType"
                cip              = "ENABLED"
                cipheader        = "X-Forwarded-For"
            }
        }
        else {
            $PayLoad = @{
                servicegroupname = "$ServiceGroupName"
                servicetype      = "$ServiceGroupType"
            }
        }
    }

    process {
        try {
            Invoke-ADCRestAPI -Session $Session -Method POST -Type "servicegroup" -Payload $PayLoad -Action Add
            write-verbose "Load Balancing Service Group ($ServiceGroupName) added to the Citrix ADC of type ($ServiceGroupType)"
        }
        catch {
            write-verbose "Load Balancing Service Group ($ServiceGroupName) could not be added to the Citrix ADC of type ($ServiceGroupType)"
        }
    }

    end {
    }
    
}