Lync/SfB PowerShell scripts

Probably the last post related to Lync/Skype for Business Server in UC Lobby

Since the first post on this blog (Enabling Trace Log in Office Communicator, Lync 2010 and Lync 2013May 2013) the focus has been to share information related to Lync/Skype for Business.

With the release of Microsoft Teams customers started their journey to move all users to Teams. This meant that my role also adapted to the trend and for a while now it has been focused on Microsoft Teams, specifically Microsoft Teams Devices (Rooms/Panels/Phones/Displays).

Occasionally, I am still engaged to decommission a Skype for Business deployment that “refuses” to go away.

For this post I decided to share some PowerShell/MSPL scripts that I wrote during my work with OCS/Lync/Skype for Business Server, these scripts were created to help troubleshoot some issues or to get information that was requested by customers.

These scripts have been sitting in my OneDrive, so it’s been a while since they were used/tested. I just wanted to publish and maybe they will still help someone.

Please comment if you have any questions about a specific script.

All these are available in GitHub (PowerShell and MSPL) and also PowerShell Gallery (PowerShell only).

Invoke-CsSQLcmd (PowerShell)

Run a SQL query to all Front Ends in a pool, if no pool is specified, it will use the current computer to check if belongs to a Lync/Skype for Business Front End Pool and execute a SQL query.

Parameters

  • PoolFqdn – Specifies the pool we want to run the SQL query.
  • SQL Instance – If we want to query RTCLOCAL or LYNCLOCAL.
  • SQLDatabase – Database where we want to execute the SQL query.
  • SQLQuery – SQL query we want to execute.
  • SQLFile – We can also create a file if the SQL query is complex.

Release Notes

  • Version 1.0: 2019/10/09 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Invoke-csSQLCmd

GitHub: https://github.com/uclobby/Invoke-csSQLCmd

Check-CsCMSStatus (PowerShell)

Returns the current Central Management Store (CMS) status when we have two paired pools (Primary and Backup).

This is useful in scenarios that we fail the CMS and end up with CMS Active/Active or Backup/Backup.

This PowerShell script doesn’t accept any parameter.

Release Notes

  • Version 1.0: 2019/06/12 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Check-CsCMSStatus

GitHub: https://github.com/uclobby/Check-CsCMSStatus

Get-CsUserRoutingGroupAssignment (PowerShell)

Returns the routing group user count from Lync/Skype for Business Front Ends.

Parameters

  • PoolFqdn – Specify the Pool FQDN that we want to get the user per routing group count.
  • ExcludeSBA – Switch if we want to exclude users that are homed on a Survivable Branch Appliance that is associated with the Front End Pool.
  • Detailed – It will output the users SIP addresses.

Release Notes

  • Version 1.0: 2019/07/16 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Get-CsUserRoutingGroupAssignment

GitHub: https://github.com/uclobby/Get-CsUserRoutingGroupAssignment

Get-CsDuplicatedRoutingGroup (PowerShell)

Returns the duplicated routing group information from Lync/Skype for Business Front Ends.

Parameters

  • PoolFqdn – Specify the Pool FQDN that we want to check for Duplicated Routing Groups.

Release Notes

  • Version 1.0: 2019/08/12 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Get-CsDuplicatedRoutingGroup

GitHub: https://github.com/uclobby/Get-CsDuplicatedRoutingGroup

Get-CsTCPConnections (PowerShell)

Returns TCP Established Connections Performance Monitor Counter from Lync/Skype for Business.

Parameters

  • ServerFqdn – Specify the Server FQDN
  • PoolFqdn – Specify Pool FQDN
  • AllPools – When this switch is used the script will get all pools in the deployment and query the TCP connections.

Release Notes

  • Version 1.0: 2016/08/19 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Get-CsTCPConnections

GitHub: https://github.com/uclobby/Get-CsTCPConnections

Split-LyssXML (PowerShell)

Split files LyssXML export files so they can be reimported to Lyss, if the files are larger the import might fail.

Parameters

  • LyssXMLFile – Lyss XML full file path.

Release Notes

  • Version 1.0: 2018/08/06 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Split-LyssXML

GitHub: https://github.com/uclobby/Split-LyssXML

Add-KB2982006 (PowerShell)

Script to add the KB2982006 when we cannot install it: SfB Server: Cannot install KB2982006 – This update is not applicable to your computer.

Parameters

  • MsuFile – Use this to specify the location of the Windows8.1-KB2982006-x64.msu if you previously download it.
  • CabFile – Use this to specify the location of the Windows8.1-KB2982006-x64.cab.

Release Notes

  • Version 1.0: 2017/11/23 – Initial release.
  • Version 1.1: 2023/10/07 – Updated to publish in PowerShell Gallery.

PowerShell Gallery: https://www.powershellgallery.com/packages/Add-KB2982006

GitHub: https://github.com/uclobby/Add-KB2982006

FileTransferBlock (MSPL)

This MSPL Script allowed to block file transfers to specific domains. It’s based on VoIPNorm:

Blocking File Transfers to Federated Users Using Lync MSPL Scripts

The AllowedDomains.txt allows to specify actions per domain:

  • both
  • sendonly
  • receiveonly
  • block

SIPDomain,Action
contoso.com,block

Release Notes

  • Version 1.0: 2017/02/02 – Initial release.

GitHub: https://github.com/uclobby/BlockFederatedFileTransfer

BlockConferenceFileUpload (MSPL)

This MSPL Script will prevent users to upload files to external meetings, it has to be deployed on the Edge Server.

Release Notes

  • Version 1.0: 2017/02/02 – Initial release.

GitHub: https://github.com/uclobby/BlockConferenceFileUpload