Get-InvalidRgsAgents.ps1

On a recent window-shopping expedition through the event logs on a customer’s Front-End I stumbled across instances of warnings 31137 & 31138. These are generated when Lync realises that users belonging to RGS Agent Groups are no longer EV-enabled, or no longer exist.

During the Active Directory update non-UC enabled agents were found.
The following users are specified as agents, but are not UC enabled…

Warning31138

Annoyingly, the messages don’t identify the Group(s) the offending users belong to. Enter “Get-InvalidRgsAgents.ps1”.

What Does It Do?

This script searches the Event Logs on the local Front-End server for the most recent instance of each error. It then extracts the SIP addresses, tests their current state and reports this information to screen. If you add one of the “-restore” or “-remove” switches, the script will take action to correct the situation:

PS C:\> .\Get-InvalidRgsAgents.ps1

SIP URI               Group Name          Owner Pool                Status          Action   Distribution Group
-------               ----------          ----------                ------          ------   ------------------
jessica@contoso.net   Main_group          lync2013se.contoso.local  OK              None     alerts@contoso.com
derwood@contoso.net   Main_group          lync2013se.contoso.local  Not in Lync/AD  None
derwood@contoso.net   Dummy Lync10 Group  lync2010.contoso.local    EV disabled     None
derwood@contoso.net   Main_group          lync2013se.contoso.local  EV disabled     None

-Restore

Any user that is confirmed to still exist in Lync but is EV-disabled will be re-enabled for Enterprise Voice. Other users won’t be touched.

PS C:\> .\Get-InvalidRgsAgents.ps1  -Restore

SIP URI               Group Name          Owner Pool                Status          Action   Distribution Group
-------               ----------          ----------                ------          ------   ------------------
jessica@contoso.net   Main_group          lync2013se.contoso.local  OK              None     alerts@contoso.com
homer@contoso.net     Main_group          lync2013se.contoso.local  Not in Lync/AD  None
derwood@contoso.net   Dummy Lync10 Group  lync2010.contoso.local    EV disabled     Restored
derwood@contoso.net   Main_group          lync2013se.contoso.local  EV disabled     Restored

-Remove

Any user that is either EV-disabled or doesn’t exist in Lync will be removed from the Group.

PS C:\> .\Get-InvalidRgsAgents.ps1  -Remove

SIP URI               Group Name          Owner Pool                Status          Action  Distribution Group
-------               ----------          ----------                ------          ------  ------------------
jessica@contoso.net   Main_group          lync2013se.contoso.local  OK              None    alerts@contoso.com
homer@contoso.net     Main_group          lync2013se.contoso.local  Not in Lync/AD  Removed
derwood@contoso.net   Dummy Lync10 Group  lync2010.contoso.local    EV disabled     Removed
derwood@contoso.net   Main_group          lync2013se.contoso.local  EV disabled     Removed

Other Features

  • On-screen progress bars just in case it takes a while to find a recent instance of the events
  • The output can be piped to a text file:
     .\Get-InvalidRgsAgents.ps1 > Output-dump.txt
  • In-built help and documentation – just run “get-help .\Get-InvalidRgsAgents.ps1”
  • If you have Response Groups across multiple pools, all are tested, however ONLY users homed to the local Front-End will be identified in that machine’s event log
  • And because it’s free-standing, you might even like to schedule it!

Revision History

v1.3 29May 2016

  • Corrected bug where invalid agents in Distribution Group resulted in the group being replaced by the list of remaining (good) agents
  • Added code-signing certificate. (Thank you DigiCert)
  • Added “-wa silentlyContinue” to suppress warning messages showing on screen if the user has unrelated config issues
  • Removed ‘width’ values from $myFormatShow & replaced with “-auto” to improve legibility on-screen
  • Added DistributionGroup as a new member to the output object
  • Changed the output object to always show Action and DistributionGroup
  • Changed command tests to try/catch blocks for improved error handling
  • Added ProgressBar to provide a visual indication as it’s reading the users returned from the event logs
  • Changed the way the Agent Groups are read – now only once, rather than repeatedly for each nominated user

v1.2 13Sept2013

  • Updated the conjoining of events 31137 & 31138 to correctly capture multiple agents (Tks again Chris)

v1.1 08Sept2013

  • Corrected bug where Event31138 entries were over-writing those of 31137. (Thanks Chris!)

v1.0 22Aug2013

  • Initial release.

Download

Click here to view the script in a new window, or Download it as a .zip file.

 

G.

5 Comments

  1. Great script! However, I am not getting all of my user results. I noticed that the Event 31138 users are stored in the $users31137 variable instead of $users31138. This creates a result set only for the users in the Event 31138. I figured I would simply update that storage variable in the code to get all the results, but it does not seem to report any users then. Any thoughts on correcting this oversight?

    Thanks,
    Chris

Leave a Reply

Your email address will not be published.

... and please just confirm for me that you're not a bot first: Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.