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 ) begin { $StartTime = (Get-Date) 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.global.MonitorPrefix $GSLBLocalServicename = $JSON.Licensing.gslb.GSLBLocalServiceName $GSLBLocalvServerName = $JSON.Licensing.gslb.GSLBLocalvServerName $GSLBRemoteServicename = $JSON.Licensing.gslb.GSLBRemoteServiceName $GSLBRemotevServerName = $JSON.Licensing.gslb.GSLBRemotevServerName $GSLBPrimaryVIP = $JSON.Licensing.gslb.GSLBPrimaryVIP $GSLBRemoteVIP = $JSON.Licensing.gslb.GSLBRemoteVIP # Generate Citrix ADC Credentials $SecurePassword = ConvertTo-SecureString $JSON.Global.ADCPassword -AsPlainText -Force $ADCCredentials = New-Object System.Management.Automation.PSCredential ($JSON.Global.ADCUserName, $SecurePassword) } process { Write-Verbose "Starting to add Citrix Licensing GSLB Configuration to the Citrix ADC" # Connect to the Citrix ADC Connect-CitrixADC -IPAddress $JSON.Global.ADCIP -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.gslb.RemoteLicenseServerVirtualServerIP # Add the 2 GSLB services Add-ADCGSLBService -ServiceName $GSLBLocalServicename -ServerName $GSLBPrimaryVIP -SiteName $JSON.global.GSLBLocalSite -Port 65535 -ServiceType "TCP" Add-ADCGSLBService -ServiceName $GSLBRemoteServicename -ServerName $GSLBRemoteVIP -SiteName $JSON.global.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.gslb.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" } end { $EndTime = (Get-Date) Write-Verbose "Add-CitrixLicensingGSLB finished." Write-Verbose "Elapsed Time: $(($EndTime-$StartTime).TotalMinutes) Minutes" Write-Verbose "Elapsed Time: $(($EndTime-$StartTime).TotalSeconds) Seconds" } } |