Private/Set-ADCMonitorToServiceGroup.ps1
function Set-ADCMonitorToServiceGroup { <# .SYNOPSIS Sets (Binds) a Monitor to a Load Balancing Service Group. .DESCRIPTION Sets (Binds) a Monitor to a Load Balancing Service Group. .PARAMETER Session The Citrix ADC Session to execute the function against. .PARAMETER ServiceGroupName The Load Balancing Service Group Name. .PARAMETER MonitorName The Monitor to bind to the Load Balancing Service. .NOTES Creation Date: 20/06/2018 .CHANGE CONTROL Name Version Date Change Detail David Brett 1.0 29/03/2018 Function Creation .EXAMPLE Set-ADCMonitorToServiceGroup -ServiceGroupName "svc_grp_citrix_storefront_443" -MonitorName "mon_citrix_storefront_443" -Verbose #> [CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Medium')] Param ( $Session = $script:session, [parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName)] [string[]]$ServiceGroupName = (Read-Host -Prompt 'Enter Service Group Name'), [string[]]$MonitorName = (Read-Host -Prompt 'Enter Monitor Name') ) begin { $PayLoad = @{ "monitorname" = $MonitorName "servicegroupname" = $ServiceGroupName } } process { try { if ($Force -or $PSCmdlet.ShouldProcess("ShouldProcess?")) { Invoke-ADCRestAPI -Session $Session -Method POST -Type "lbmonitor_servicegroup_binding" -Payload $PayLoad -Action Add write-verbose "Monitor ($MonitorName) bound to Service Group ($ServiceGroupName)" } } catch { write-verbose "Monitor ($MonitorName) could not be bound to Service Group ($ServiceGroupName)" } } end { } } |