Public/Add-CitrixLicensingGSLB.ps1
function Add-CitrixLicensingGSLB { <# .SYNOPSIS Adds a Citrix Licensing Active / Passive Global Server Load Balancing configuration to your Citrix ADC. .DESCRIPTION Adds a Citrix Licensing Active / Passive Global Server Load Balancing configuration to your Citrix ADC. The configuration data for this function is driven by the "Licensing" section of the JSON file passed in. .PARAMETER JSONFile The JSON file containing the data to be used to configure the Citrix Licensing GSLB configuration. .NOTES Creation Date: 29/03/2018 .CHANGE CONTROL Name Version Date Change Detail David Brett 1.0 29/03/2018 Function Creation .EXAMPLE Add-CitrixLicensingGSLB -JSONFile C:\CitrixADC\CitrixADC-Build.json Add-CitrixLicensingGSLB -JSONFile C:\CitrixADC\CitrixADC-Build.json -Verbose #> [CmdletBinding()] Param ( [parameter(Mandatory = $false, ValueFromPipeline = $true)][string[]]$JSONFile ) # Read in the JSON File if (test-path $JSONfile) { try { $JSON = Get-Content -Raw -Path $JSONfile | ConvertFrom-Json -ErrorAction Stop } catch { throw "Error reading JSON. Please Check File and try again." } } # Read in data from the JSON File $MonitorPrefix = $JSON.Licensing.MonitorPrefix $GSLBLocalServicename = $JSON.Licensing.GSLBLocalServiceName $GSLBLocalvServerName = $JSON.Licensing.GSLBLocalvServerName $GSLBRemoteServicename = $JSON.Licensing.GSLBRemoteServiceName $GSLBRemotevServerName = $JSON.Licensing.GSLBRemotevServerName $GSLBPrimaryVIP = $JSON.Licensing.GSLBPrimaryVIP $GSLBRemoteVIP = $JSON.Licensing.GSLBRemoteVIP # Generate Citrix ADC Credentials $SecurePassword = ConvertTo-SecureString $JSON.Global.ADCPassword -AsPlainText -Force $ADCCredentials = New-Object System.Management.Automation.PSCredential ($JSON.Global.ADCUserName, $SecurePassword) Write-Verbose "Starting to add Citrix Licensing GSLB Configuration to the Citrix ADC" # Connect to the Citrix ADC Connect-CitrixADC -IPAddress $JSON.Global.NetScalerIP -Credential $ADCCredentials # Add the local and remote Citrix Licensing servers Add-ADCServer -ServerName $GSLBPrimaryVIP -ServerIP $JSON.Licensing.LicenseServerVirtualServerIP Add-ADCServer -ServerName $GSLBRemoteVIP -ServerIP $JSON.Licensing.RemoteLicenseServerVirtualServerIP # Add the 2 GSLB services Add-ADCGSLBService -ServiceName $GSLBLocalServicename -ServerName $GSLBPrimaryVIP -SiteName $JSON.Licensing.GSLBLocalSite -Port 65535 -ServiceType "TCP" Add-ADCGSLBService -ServiceName $GSLBRemoteServicename -ServerName $GSLBRemoteVIP -SiteName $JSON.Licensing.GSLBRemoteSite -Port 65535 -ServiceType "TCP" # Bind Citrix Licensing Monitors to Local GSLB Service Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBLocalServicename -MonitorName $MonitorPrefix'citrix_licensing_27000' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBLocalServicename -MonitorName $MonitorPrefix'citrix_licensing_7279' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBLocalServicename -MonitorName $MonitorPrefix'citrix_licensing_8082' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBLocalServicename -MonitorName $MonitorPrefix'citrix_licensing_8083' # Bind Citrix Licensing Monitors to Remote GSLB Service Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBRemoteServicename -MonitorName $MonitorPrefix'citrix_licensing_27000' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBRemoteServicename -MonitorName $MonitorPrefix'citrix_licensing_7279' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBRemoteServicename -MonitorName $MonitorPrefix'citrix_licensing_8082' Set-ADCMonitorToGSLBService -GSLBServiceName $GSLBRemoteServicename -MonitorName $MonitorPrefix'citrix_licensing_8083' # Add the Local and Remote GSLB vServers Add-ADCGSLBvServer -vServerName $GSLBLocalvServerName -ServiceType "TCP" Add-ADCGSLBvServer -vServerName $GSLBRemotevServerName -ServiceType "TCP" # Bind the GSLB Services to the new GSLB vServers Set-ADCGSLBServiceTovServer -vServerName $GSLBLocalvServerName -ServiceName $GSLBLocalServicename Set-ADCGSLBServiceTovServer -vServerName $GSLBRemotevServerName -ServiceName $GSLBRemoteServicename # Add the GSLB Domain Name Add-ADCGSLBDomainTovServer -vServerName $GSLBLocalvServerName -DomainName $json.Licensing.GSLBDomainName # Bind the backup GSLB vServer to the Primary GSLB vServer Set-ADCGSLBvServerBackup -vServerName $GSLBLocalvServerName -BackupvServerName $GSLBRemotevServerName # Disconnect from the Citrix ADC Disconnect-CitrixADC Write-Verbose "Finished adding Citrix Licensing GSLB Configuration to the Citrix ADC" } |