Disable Lync accounts for users disabled in AD

Hi all,
few days ago I had to do some clean up tasks at one of our customer. Goal was to disable Lync accounts for users, that do not work for company anymore.

It seems like a powershell mission. To get list of disabled AD accounts that still have enabled Lync you can use following line:


Get-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match"AccountDisabled" -and $_.Enabled -eq $true} | Format-Table Name,Enabled,SipAddress -auto

Then you can easily remove Lync account by using following line:

Get-CsAdUser -ResultSize Unlimited | Where-Object {$_.UserAccountControl -match"AccountDisabled" -and $_.Enabled} | Disable-CsUser


Komentáře

Populární příspěvky z tohoto blogu

Copy Group Membership to another user

Set up Auto Logon in Windows using PowerShell

Lync 2013 Persistent Chat Service not starting