Home > Lync Server/Skype for Business Server > Script: Get-CsDatabaseUpdateStatus.ps1 – See If Your Lync Databases Are Up To Date

Script: Get-CsDatabaseUpdateStatus.ps1 – See If Your Lync Databases Are Up To Date

Description

Anyone who has updated a Lync or Skype for Business environment with a recent Cumulative Update knows that there are often manual steps to perform after the LyncServerUpdateInstaller.exe/SkypeServerUpdateInstaller.exe program is finished. These are often database update functions. And often, multiple functions to update the various different databases, including the CMS, monitoring, archiving, Persistent Chat, etc. I’ve run across quite a few environments where the LyncServerUpdateInstaller.exe/SkypeServerUpdateInstaller.exe is run, and nothing else is done, and the client can’t figure out why things aren’t running as they expect. Fortunately, the Test-CsDatabase cmdlet will show you the current version of the database and the expected version. But then you have to manually compare each one to determine if an update is required. Of course, there are databases on the local Front End server(s), and the SQL backend server(s). Also, it’s important to review the status of SQL mirroring, and ensuring that databases are active on the principal node and not the mirror node. And that’s just part of the patching process.

Dave Howe, of the Lync product group, and I collaborated on a script that helps streamline part of this process. Dave did a lot of the initial grunt work, so he deserves a lot of the credit. I cleaned things up and optimized per some best practices.

Among the tasks that this script performs:

Determines whether database updates are required. It performs the following checks:

  1. Detects whether the pool version is Lync Server 2013 or later, including Skype for Business
  2. Detects whether database mirroring is enabled
  3. Detects whether the primary and mirror SQL servers are online
  4. Detects whether the mirror server is principal for any databases
  5. Detects whether the local machine is a FE of the given pool
  6. Detects whether the CMS is on Lync Server 2013 or later, including Skype for Business

And returns the following info:

  1. Returns list of local databases, their versions, and whether a database update is required (if the local server is a member of the pool)
  2. Returns list of backend databases, their versions, and whether a database update is required
  3. Returns list of CMS databases, their versions, and whether a database update is required

An example output is shown below. Note that the local XDS database requires an update

Get-CsDatabaseUpdateStatus2

Syntax

Get-CsDatabaseUpdateStatus.ps1 [[-PoolFqdn] ] [-WhatIf] [-Confirm] []

Installation

Execution Policy: Third-party PowerShell scripts may require that the PowerShell Execution Policy be set to either AllSigned, RemoteSigned, or Unrestricted. The default is Restricted, which prevents scripts – even code signed scripts – from running. For more information about setting your Execution Policy, see Using the Set-ExecutionPolicy Cmdlet.

Donations

I’ve never been one to really solicit donations for my work. My offerings are created because *I* need to solve a problem, and once I do, it makes sense to offer the results of my work to the public. I mean, let’s face it: I can’t be the only one with that particular issue, right? Quite often, to my surprise, I’m asked why I don’t have a “donate” button so people can donate a few bucks. I’ve never really put much thought into it. But those inquiries are coming more often now, so I’m yielding to them. If you’d like to donate, you can send a few bucks via PayPal at https://www.paypal.me/PatRichard. Money collected from that will go to the costs of my website (hosting and domain names), as well as to my home lab.

Assumptions

None

Download

v1.2 – 02-24-2018 – Get-CsDatabaseUpdateStatus.v1.2.zip

v1.1 – 04-30-2014 – Get-CsDatabaseUpdateStatus.v1.1.zip

v1.0 – 04-30-2014 – Get-CsDatabaseUpdateStatus.v1.0.zip

Changelog

See the changelog for information on what’s changed/included in each version.

  1. April 30th, 2014 at 13:56 | #1

    I get :
    At C:\Users\admin-ten\Get-CsDatabaseUpdateStatus.ps1:69 char:2
    + param()
    + ~~~~~~~
    The param statement cannot be used if arguments were specified in the function
    declaration.

    • Pat Richard
      May 1st, 2014 at 09:48 | #2

      Download v1.1

  2. David Taig
    May 7th, 2014 at 11:14 | #3

    For the example above, you need to apply the Central Management Database update for xds

    Install-CsDatabase -CentralManagementDatabase -SqlServerFqdn CMS.FQDN -SqlInstanceName DBInstanceName -Verbose

    Ref: http://support.microsoft.com/kb/2809243

    • Pat Richard
      May 7th, 2014 at 11:16 | #4

      Yep, I know. Intentionally left it not updated so I could grab the screenshot.

  3. john Marques
    September 17th, 2014 at 15:15 | #5

    This scripts does not function with Lync 2010 server since the cmdlets it executing are 2013 cmdlets. Is there a 2010 version. what are my options?

    • Pat Richard
      September 17th, 2014 at 15:47 | #6

      It was not designed for 2010. It works for 2013 and later. I have no plans on supporting 2010 with this script. Sorry.

  4. Parthiban
    November 18th, 2014 at 07:45 | #7

    Hi Pat,

    I have Ran this script it worked but it showed Update required No. I am going to update Cu5 on all the front end so once after the installation i have to run to verify whether it has some updates?

    • Pat Richard
      November 18th, 2014 at 08:45 | #8

      “No” means that no update is required based on the CU that’s already installed. Once you install CU5, it will show as “Yes” until you do the manual DB steps.

  5. Andy Meyers
    December 10th, 2014 at 16:50 | #9

    So I’m up to the August 2014 CU (5.0.8308.738) and all of my front ends show this…

    rtcdyn 125.6.4 0.0.0 yes

    I noticed the rtcdyn in your screenshot appears similar in terms of versions but does not indicate an update is required. Thoughts?

  6. Richard
    January 5th, 2015 at 08:39 | #10

    Hi Pat,

    I get a strange line in the output:
    local database: RTCDYN reports the expected version should be 125.6.5 but installedversion says: 0.0.0 and it marks it as UpdateRequired=YES.

    I saw in your screenshot, that you also have installedversion as 0.0.0, but yours is not marked as require update. Is this normal to see 0.0.0 for that particular DB (thats the only one which has this 0.0.0 all others show normal-looking numbers) and how to decide if I need to update it or not? (for the record my example is from a Lync 2013 SE pool/server deployment with the 2014.12.31 update already run, including all the DB updates as well).

    • Pat Richard
      January 5th, 2015 at 11:24 | #11

      That’s a known issue with the last few CUs. MS is aware of it. The script is correctly reporting what the DB is configured as (0.0.0.0), but the update is already applied (assuming there was no errors during the DB updates).

      • Richard
        January 5th, 2015 at 17:09 | #12

        Thanks, at least I know the triple 0 is as expected. I dont know though how should I update that RTCDYN so that the script marks as up-to-date. I run the update cmdlet couple of times, but no surprise the situation didnt change after.

        • Pat Richard
          January 5th, 2015 at 17:11 | #13

          You can’t really do anything about it. The version being reported is < than the expected version - so it's going to show as an update being required. And the version isn't stored as a string in the DB. It's essentially a construct.

  7. Shaik
    March 20th, 2015 at 08:13 | #14

    Local Databases

    DatabaseName ExpectedVersion InstalledVersion UpdateRequired
    ———— ————— —————- ————–
    rtcdyn 125.6.5 0.0.0 yes

    Central Management Databases:

    DatabaseName ExpectedVersion InstalledVersion UpdateRequired
    ———— ————— —————- ————–
    xds 10.13.3 10.13.1 yes

    I got updaterequired “yes” for two databases after upgrading CU10 is it normal else how can I correct it?

  1. April 30th, 2014 at 20:27 | #1
  2. May 7th, 2014 at 03:52 | #2
  3. August 6th, 2014 at 19:26 | #3
  4. October 30th, 2014 at 07:37 | #4
  5. November 22nd, 2014 at 00:41 | #5
  6. December 15th, 2014 at 01:38 | #6
  7. January 1st, 2015 at 15:52 | #7