Thursday, 2 May 2013

Useful Lync Powershell Commands


While deployment or troubleshooting I always need number of useful powershell commands ( I don't trust my memory ) So I thought I will dump all in here for my reference in future. ( May be useful to someone else as well )


      ·         Enable user for Lync
      Enable-CsUser "Fname Lname" -RegistrarPool "poolname.domain.com" -SipAddressType EmailAddress
      ·         Enable user for Enterprise Voice
      Set-CsUser "Fname Lname" -EnterpriseVoiceEnabled:$True -LineURI "tel:+613xxxxxxxx;ext=xxxx"
      ·         Create Common Area Phone
      New-CsCommonAreaPhone -RegistrarPool "poolname.domain.com" -DisplayName "Warehouse" -OU "OU=Lync,DC=domain,DC=com" -DisplayNumber "+613xxxx xxxx" -LineURI "tel:+613xxxxxxxx;ext=xxxx"
      ·         Assign a PIN
      Set-CsClientPin "Fname Lname" -Pin 2468
      ·         Determine number of users enabled for EV
      (Get-CsUser | Where {$_.EnterpriseVoiceEnabled -eq $True}).Count
      ·         Determine number of common Area phone
      (Get-CsCommonAreaPhone).Count
       
      ·         Set Location Policy
      Set-CsLisSubnet -Subnet 172.17.181.0 -Description "" -Location "Melbourne" -CompanyName "Company Name Here" -HouseNumber "53" -HouseNumberSuffix "" -PreDirectional "" -StreetName "Lync" -StreetSuffix "St" -PostDirectional "" -City "Melbourne" -State "" -PostalCode "4000" -Country "AU"
      ·         If you’ve not been disabling users in Lync while disabling them in AD, here’s a one liner to find those users: ( Thanks to Ehloworld – Blog link )
      Get-CsAdUser | ?{$_.UserAccountControl -match "AccountDisabled" -and $_.Enabled -eq $true} | ft Name,Enabled,SipAddress -auto
      ·         You can get a count of the users using:
      Get-CsAdUser | ?{$_.UserAccountControl -match "AccountDisabled" -and $_.Enabled -eq $true} | Measure-Object
      ·         if you want, can disable them in one line using
      Get-CsAdUser | ?{$_.UserAccountControl -match "AccountDisabled" -and $_.Enabled -eq $true} | Disable-CsUser
        ·         Get list of users with format table
         
        Get-CsUser | Format-Table -wrap -Property DisplayName, SipAddress, Registrarpool, LineUri  >C:\Extensions1.txt
     

       


      No comments:

      Post a Comment