Private/Add-ADCCustomTCPMonitor.ps1

function Add-ADCCustomTCPMonitor {
    <#
.SYNOPSIS
    Adds a Custom TCP Monitor to the Citrix ADC.
.DESCRIPTION
    Adds a Custom TCP Monitor to the Citrix ADC.
.PARAMETER Session
    The Citrix ADC Session to execute the function against.
.PARAMETER MonitorName
    The Monitor Name.
.PARAMETER MonitorPort
    The Monitor Port.
.NOTES
    Creation Date: 20/06/2018
.CHANGE CONTROL
    Name Version Date Change Detail
    David Brett 1.0 29/03/2018 Function Creation
.EXAMPLE
    Add-ADCCustomTCPMonitor -MonitorName "mon_storefront_8080" -MonitorPort 8080 -Verbose
#>


    [CmdletBinding()]
    Param (
        $Session = $script:session,
        [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)]
        [string[]]$MonitorName = (Read-Host -Prompt 'Enter Custom TCP Monitor Name'),
        [string[]]$MonitorPort = (Read-Host -Prompt 'Enter Custom TCP Monitor Port')
    )

    begin {
        $PayLoad = @{
            monitorname = "$MonitorName"
            type        = "TCP"
            destport    = "$MonitorPort"
        }
    }

    process {
        try {
            Invoke-ADCRestAPI -Session $Session -Method POST -Type "lbmonitor" -Payload $PayLoad -Action Add
            write-verbose "Custom TCP Monitor ($MonitorName) added to the Citrix ADC on Port ($MonitorPort)"
        }
        catch {
            write-verbose "Custom TCP Monitor ($MonitorName) could not be added to the Citrix ADC on Port ($MonitorPort)" 
        }
    }

    end {
    }
    
}