{"id":1133,"date":"2014-06-23T00:01:00","date_gmt":"2014-06-23T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2014\/06\/23\/managing-lync-server-2013-with-windows-powershellpart-1\/"},"modified":"2014-06-23T00:01:00","modified_gmt":"2014-06-23T00:01:00","slug":"managing-lync-server-2013-with-windows-powershellpart-1","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/managing-lync-server-2013-with-windows-powershellpart-1\/","title":{"rendered":"Managing Lync Server 2013 with Windows PowerShell&#8212;Part 1"},"content":{"rendered":"<p><b>Summary<\/b>: Use Windows PowerShell to enable Active Directory users for Lync.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;Hey, Scripting Guy! We just spun up our Lync server, and I need to know a very easy way to enable groups of users. I have over 10,000 records to enable and not quite enough coffee to click the mouse button all that fast!<\/p>\n<p>&mdash;LN<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Hello LN,<\/p>\n<p>Honorary Scripting Guy, Sean Kearney, is here to show you a way to get all those users enabled without burning out the left mouse button!<\/p>\n<p>If you&#039;re new to managing Lync Server 2013, your first experience probably has been your visit to the Lync Server Control Panel.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4722.1.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4722.1.png\" alt=\"Image of menu\" title=\"Image of menu\" \/><\/a><\/p>\n<p>You found it well enough organized to click the option &quot;Enable users for Lync Server.&quot; It brought up this ever so lovely console:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6710.2.png\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6710.2.png\" alt=\"Image of menu\" title=\"Image of menu\" \/><\/a><\/p>\n<p>Enabling a user or two isn&#039;t quite so difficult. But how about enabling a whole slew of them? For that, we can turn to our good friend Windows PowerShell.<\/p>\n<p>To access the Lync PowerShell cmdlets, you need only launch Lync Server Management Shell. But if you prefer, you can run the cmdlets from an ordinary Windows PowerShell console. Simply launch this line in Windows PowerShell on the Lync Server:<\/p>\n<p style=\"margin-left:30px\">IMPORT-MODULE Lync<\/p>\n<p>At this point, you are in the wonderful world of Windows PowerShell and Lync. Now we can create a user with this cmdlet:<\/p>\n<p style=\"margin-left:30px\">ENABLE-CSADUser<\/p>\n<p>With this cmdlet you can take all the values you would normally key into the GUI and drop them into a repeatable line. &nbsp;For example, Mr. Dent would be enabled in the following manner:<\/p>\n<p style=\"margin-left:30px\">ENABLE-CSAduser &ndash;identity &#039;Arthur Dent&#039; &ndash;RegistrarPool &#039;eot-lync.contoso.local&#039; &ndash;sipaddresstype FirstnameLastname &ndash;sipdomain contoso.local<\/p>\n<p>With that, Mr. Dent (who remembered to bring his towel, of course) can now happily hop into Lync and chat about with&hellip;well&#8230;nobody.<\/p>\n<p>He was, after all, our first user. If this is a scenario in which I am going to enable many users (or maybe 10,000 users&mdash;in which case, it would be &quot;Many, many, many users,&quot; as they said in Policy Academy), we would do things differently.<\/p>\n<p>First, the simplest action of them all would be to target an organizational unit in Active Directory. Let&#039;s pick on the HitchHiker&#039;s organizational unit today. Everybody in that organizational unit will become Lync enabled. Use the <b>Get-AdUser<\/b> cmdlet as you normally would to get the users:<\/p>\n<p style=\"margin-left:30px\">GET-Aduser &ndash;filter * -searchbase &#039;OU=GuideToGalaxy,OU=Hitchhikers,DC=Contoso,DC=local&#039;<\/p>\n<p>We can now pipe in that list directly to the <b>Enable CS-ADuser <\/b>cmdlet&hellip;<\/p>\n<p>Or can we?<\/p>\n<p>It turns out that this particular cmdlet is geared towards one user at a time, and it will only accept single elements, not an array. So we&#039;ll have to split up the data with a <b>Foreach<\/b> statement like so:<\/p>\n<p style=\"margin-left:30px\">GET-Aduser &ndash;filter * -searchbase &#039;OU=GuideToGalaxy,OU=Hitchhikers,DC=Contoso,DC=local&#039; | Foreach { ENABLE-CSAduser &ndash;identity $_.Name &ndash;RegistrarPool &#039;eot-lync.contoso.local&#039; &ndash;sipaddresstype FirstnameLastname &ndash;sipdomain contoso.local }<\/p>\n<p>I found the cmdlet was actually pretty user-friendly. When I was trying to figure out the different <b>SipAddressType<\/b> values, I used <b>Tab-Complete<\/b> to scroll through the potential values. Or you can simply put in a bad value, such as <b>Towel<\/b>, and watch the lovely red error message pop up with the correct potential values listed on the screen!<\/p>\n<p style=\"margin-left:30px\">Enable-CsUser : Cannot bind parameter &#039;SipAddressType&#039;. Cannot convert value &quot;towel&quot; to type<\/p>\n<p style=\"margin-left:30px\">&quot;Microsoft.Rtc.Management.AD.Cmdlets.AddressType&quot;. Error: &quot;Unable to match the identifier name towel to a valid<\/p>\n<p style=\"margin-left:30px\">enumerator name. Specify one of the following enumerator names and try again: FirstLastName, EmailAddress,<\/p>\n<p style=\"margin-left:30px\">UserPrincipalName, SAMAccountName, None&quot;<\/p>\n<p>I thought that was pretty nice!<\/p>\n<p>So you can be as creative as you like with enabling users, targeting groups, or simply using a CSV file, if you like. I found that after I had initially enabled staff in Lync, I was using the one-line command to enable them in my onboarding script as I created them in Active Directory.<\/p>\n<p>But we all do it a little differently.<\/p>\n<p>Pop back in tomorrow as we check out even more Lync cmdlets!<\/p>\n<p>I invite you to follow The Scripting Guys on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\" target=\"_blank\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\" target=\"_blank\">Facebook<\/a>. If you have any questions, send an email to The Scripting Guys at <a href=\"mailto:scripter@microsoft.com\" target=\"_blank\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/bit.ly\/scriptingforum\" target=\"_blank\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then remember to eat your cmdlets each and every day with a dash of creativity.<\/p>\n<p><b>Sean Kearney<\/b>, Windows PowerShell MVP and Honorary Scripting Guy<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to enable Active Directory users for Lync. &nbsp;Hey, Scripting Guy! We just spun up our Lync server, and I need to know a very easy way to enable groups of users. I have over 10,000 records to enable and not quite enough coffee to click the mouse button all that fast! [&hellip;]<\/p>\n","protected":false},"author":596,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[56,389,154,45],"class_list":["post-1133","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-guest-blogger","tag-lync","tag-sean-kearney","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to enable Active Directory users for Lync. &nbsp;Hey, Scripting Guy! We just spun up our Lync server, and I need to know a very easy way to enable groups of users. I have over 10,000 records to enable and not quite enough coffee to click the mouse button all that fast! [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1133","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/596"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=1133"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/1133\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=1133"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=1133"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=1133"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}