Lync PowerShell Snippets

Here’s an ad-hoc post with a collection of snippets of PowerShell I often seem to find myself needing to refer to.

There are some more good ones here from Paul Bloem, over the pond.

How do I find (and/or count) the users homed to a given FE/pool?

Get-CsUser | Where-Object {$_.RegistrarPool -match "<POOL FQDN>"} | measure

How about the users still on OCS?

Get-CsUser -OnOfficeCommunicationServer | Measure

How can I count the number of users who are enabled for Enterprise Voice?

Get-CsUser | Where-Object {$_.EnterpriseVoiceEnabled -match "true"} | measure

… or a combo: who’s on this pool AND enabled for Enterprise Voice?

Get-CsUser -filter {registrarpool -eq "<POOL FQDN>"} | where-object {$_.EnterpriseVoiceEnabled -match $True} | ft DisplayName,SipAddress,LineUri,RegistrarPool >> EV-userlist.txt

How do I find and relocate all of the Lync users in a given OU?

Get-CsUser -OU "OU=Users,OU=Sydney,OU=australia,DC=contoso,DC=com,DC=au" | Move-CsUser –Target –verbose

How can I find out who’s using a particular number? (NB: this isn’t going to reveal if the number’s being used by a Response Group, a Private Line, Analog or Common Area phone)

Get-CsUser | ?{$_.LineURI –like “Tel:+61270001234”}

How can I find if/what Common Area (or Analog) phone is using a particular number?

Get-CsCommonAreaPhone | where-object {$_.lineuri -like "*1234*"}

How do I create objects using values from a CSV file?

import-csv "C:\CommonAreaPhones.csv" | foreach {New-CsCommonAreaPhone -RegistrarPool -OU "ou=Service Accounts,dc=contoso,dc=com,dc=au" -DisplayNumber $_.DisplayNumber -DisplayName $_.Name -LineURI $_.LineURI } -verbose > c:\CommonAreaPhones-results.txt

Check for everyone who’s not yet set a dialin conferencing PIN and set one for them

get-csuser | Get-CsClientPinInfo | Where-Object {$_.IsPinSet -match "False"} | measure
get-csuser | Get-CsClientPinInfo | Where-Object {$_.IsPinSet -match "False"} | Set-CsClientPin -Pin "1234"

How do I find where the CMS is located?


How do I see ALL of the members of an array? (Refer this post)

PS > $FormatEnumerationLimit
PS > $FormatEnumerationLimit=-1

How do I get PowerShell to spit an error when I ask for objects or properties that don’t exist, rather than just output a blank line?

Set-StrictMode –Version "Latest"
Set-StrictMode –off

(Strict mode can be REALLY helpful when you’re fishing around in the dark trying to cobble together a funky command string and aren’t sure if the null outputs are empty values, or you’re asking for stuff that doesn’t exist). (Credit).

I have a VAST deployment. I only want to see the servers that aren’t replicating:

Get-CsManagementStoreReplicationStatus | Where-Object {$_.UpToDate -eq $False}

Restart any stopped Lync services (thanks Pat):

Get-CsWindowsService -ExcludeActivityLevel | ? {$_.Status -like "Stopped"} | Start-CsWindowsService

Not strictly *Lync* PowerShell, this will tell you the version of all the installed Lync components. (It’s the PowerShell equivalent of running ServerUpdateInstaller.exe from a CU to see what CU you’re currently at). [I’ve seen this posted HERE and HERE, and I don’t know who the original author is. Credit to you, whoever you may be!]

Get-WmiObject –query ‘select * from win32_product’ | where {$ –like “Microsoft Lync Server*”} | ft Name, Version –AutoSize




  1. Hi, great article. I would recommend to use he -filter capabilities of the cmdlets though. Should be much faster. Example: get-csuser -filter {Registrarpool -eq “”} | measure-object. Try it out.

Leave a Reply to Paul-Christiaan Cancel reply

Your email address will not be published. Required fields are marked *

... 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.