<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' gd:etag='W/&quot;DU4HQ3c9eSp7ImA9WhVbF0Q.&quot;'><id>tag:blogger.com,1999:blog-117485849011714731</id><updated>2012-06-04T01:18:52.961-07:00</updated><title>Automatically enable users for Lync 2010</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://lyncdirectory.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/117485849011714731/posts/default?redirect=false&amp;v=2'/><link rel='alternate' type='text/html' href='http://lyncdirectory.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sachin Gangarde</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-C-u5Dbcu5Dw/AAAAAAAAAAI/AAAAAAAAAD0/7ogao0XAM6I/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>1</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry gd:etag='W/&quot;CUQBQH89fCp7ImA9WhVbF0Q.&quot;'><id>tag:blogger.com,1999:blog-117485849011714731.post-5461139928677778525</id><published>2012-06-03T22:17:00.002-07:00</published><updated>2012-06-04T00:02:31.164-07:00</updated><app:edited xmlns:app='http://www.w3.org/2007/app'>2012-06-04T00:02:31.164-07:00</app:edited><title></title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
&lt;span style="font-family: Calibri;"&gt;To enable user in In Lync 2010, we have to use either the Lync 
Server Management Shell or the web-based Lync Control Panel, but most of the times the need arises that the users should be enabled automatically. So to perform this task manually&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt; is too cumbersome for many 
admins, especially in situations where almost everyone in an 
organization has to be enabled for Lync. &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;So I have written the Power shell script to automate this task. The script navigates through the entire domain and find for disabled(for Lync) AD user. After finding them it enbles them on the basis of "UserPrincipalName"&amp;nbsp; as a sip address type. You can provide any type like email address, display name etc.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="color: magenta;"&gt;
&lt;span style="font-family: Calibri;"&gt;File Name : enable.ps1&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style="color: blue;"&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;span style="color: lime;"&gt;Import-Module ActiveDirectory;&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;$ouname=Get-ADOrganizationalUnit -filter * | select-object -property Name;&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;import-module 'C:\Program Files\Common Files\Microsoft Lync Server 2010\Modules\Lync\Lync.psd1';&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;$c=$ouname.count+1;&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;$arr= new-object String[] $c;&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;for($i=0; $i -le $ouname.count; $i++){$arr[$i]=$ouname[$i];};&lt;/span&gt;&lt;br style="color: lime;" /&gt;&lt;br style="color: lime;" /&gt;&lt;span style="color: lime;"&gt;for($j=0; $j -le $c-2; $j++ ){$a=$arr[$j].Replace("@{Name=",""); $b=$a.Replace("}",""); get-csaduser -filter {Enabled -ne $True} -OU "ou=$b,dc=demodomain,dc=com" | Enable-CsUser -RegistrarPool "pool1.demodomain.com" -SipAddressType userprincipalname -SipDomain "demodomain.com" };&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;So, lets understsnd what has done:&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;Firstly, we have to import module of &lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;ActiveDirectory to list all the OU's in Active Directory. The line below that gets all OU names into $ouname variable.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;Now, to execute Lync command, we have to import Lync module in Powershell.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;The followinf three lines are to get Ou name in proper format, because second line gives output in the format of "@{Name=testou}" so while sending the name of OU to script we have to trim "@{Name=" and "}".&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;The last line navigates through entire domain of Active Directory and finds disabled user for Lync and enables them on the basis of Sip Address type as UserPrincipalName. &lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;So now it's important to schedule it to run automatic; So we can use task scheduler or batch file script to schedule it execute at particular time interval.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="color: magenta;"&gt;
&lt;span style="font-family: Calibri;"&gt;File Name : enableuser.bat&lt;/span&gt;&lt;/div&gt;
&lt;span style="color: lime;"&gt;&lt;span style="font-family: Calibri;"&gt;:msg&lt;br /&gt;@COLOR 4&lt;br /&gt;@ECHO ON&lt;br /&gt;@ECHO "Please, don't close this window"&lt;br /&gt;@ECHO "AgreeYa Mobility"&lt;br /&gt;&lt;br /&gt;:StartPS&lt;br /&gt;@ECHO OFF&lt;br /&gt;powershell.exe -noprofile -executionpolicy Unrestricted -file enable.ps1&lt;br /&gt;&lt;br /&gt;@ timeout 60&lt;br /&gt;@ cls&lt;br /&gt;goto msg&lt;/span&gt;&lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="color: yellow;"&gt;
&lt;span style="font-family: Calibri;"&gt;The above batch file script excutes the &lt;/span&gt;&lt;span style="font-family: Calibri;"&gt;&lt;span style="color: magenta;"&gt;enable.ps1&lt;/span&gt; file for every 60 second. If you don't want echo then, add another line at starting of script @echo off.&lt;/span&gt;&lt;/div&gt;
&lt;div style="color: yellow;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="color: yellow;"&gt;
&lt;span style="font-family: Calibri;"&gt;Just place above two files at any place and double click on enableuser.bat, magic will start. &lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/117485849011714731-5461139928677778525?l=lyncdirectory.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://lyncdirectory.blogspot.com/feeds/5461139928677778525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://lyncdirectory.blogspot.com/2012/06/to-enable-user-in-in-lync-2010-we-have.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/117485849011714731/posts/default/5461139928677778525?v=2'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/117485849011714731/posts/default/5461139928677778525?v=2'/><link rel='alternate' type='text/html' href='http://lyncdirectory.blogspot.com/2012/06/to-enable-user-in-in-lync-2010-we-have.html' title=''/><author><name>Sachin Gangarde</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-C-u5Dbcu5Dw/AAAAAAAAAAI/AAAAAAAAAD0/7ogao0XAM6I/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>