Monday, 28 May 2012

Listing Lync Server IP Addresses

Today I had to compile a list of Lync mediation server IP addresses so that we could create firewall rules to allow traffic from the Lync 2010 edge servers and reverse proxies to the internal servers. I found that there was no easy way to do this using the existing admin tools, and it would have been a slow and repetitive manual lookup of each service and hostname.

To create a repeatable way I could get the IP addresses of these servers I came up with this PowerShell one-liner:

Get-CsPool | ? {$_.Services -like "MediationServer*"} | Select Computers -ExpandProperty Computers | % {$Hostname = $_; $IPAddress = [System.Net.Dns]::GetHostAddresses($Hostname) | ? {$_.AddressFamily -eq "InterNetwork"}; Write-Host $IPAddress,$Hostname}

This command will get all the Lync 2010 Mediation Servers in the topology, expand the computer names from each pool, use a .Net call to get the IPv4 IP address, then output a list of IP addresses and hostnames.

For readbility, the same command can be written across several lines as this:

Get-CsPool | ? {$_.Services -like "MediationServer*"} `
| Select Computers -ExpandProperty Computers `
| % {$Hostname = $_; $IPAddress = [System.Net.Dns]::GetHostAddresses($Hostname) `
| ? {$_.AddressFamily -eq "InterNetwork"}; Write-Host $IPAddress,$Hostname}

The command could easily be changed to list IP addresses for other roles (such as Web or Edge) by changing "MediationServer*" to something else (such as "Web*" or "Edge*")

- Ben

Wednesday, 2 May 2012

Automating Backups of Lync 2010 Configuration

As we planned for Lync DR it became clear that I needed a way to create backups of our Lync server and user configuration and so that we could restore service in an alternate site in the event of a disaster.

Lync provides Lync PowerShell cmdlets in the Lync Management Shell for backing up some data (the CMS and LIS databases), there is a resource kit tool for backing up Response Groups, and the DbImpExp.exe tool for backing up user data in the event you need to re-home users to another pool and their primary registrar is unavailable. The DbImpExp tool is limited in that for a Lync Server 2010, Standard Edition server you must run it locally because the SQL instance is configured to only accept local connections.

To bring these tools together, and to centralise the process for taking Lync config backups, I created this script. It requires the Lync 2010 resource kit and the Lync admin tools installed where it is run. It will enumerate the topology and back up RGS data for all app pools and user data for all registrars. You'll need to make sure that WinRM is configured to accept remote connections on Lync Standard Edition servers so that the DbImpExp command can be invoked remotely.