{"id":2760,"date":"2013-10-07T00:01:00","date_gmt":"2013-10-07T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2013\/10\/07\/use-powershell-to-bulk-create-new-conference-rooms\/"},"modified":"2013-10-07T00:01:00","modified_gmt":"2013-10-07T00:01:00","slug":"use-powershell-to-bulk-create-new-conference-rooms","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/use-powershell-to-bulk-create-new-conference-rooms\/","title":{"rendered":"Use PowerShell to Bulk Create New Conference Rooms"},"content":{"rendered":"<p><strong>Summary<\/strong>: Guest blogger, Tim Bolton, discusses how he used Windows PowerShell to create a bunch of new conference rooms.\nMicrosoft Scripting Guy, Ed Wilson, is here. Today we have another guest blog post by Tim Bolton. In one way, today&rsquo;s post is a continuation of the post we published on Friday about adding carriage returns to .csv files. It would be a good idea to review that post before reading today&rsquo;s:<\/p>\n<p style=\"padding-left: 30px\"><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2013\/10\/04\/csv-add-a-carriage-return-for-powershell-import.aspx\" target=\"_blank\">CSV: Add a Carriage Return for PowerShell Import<\/a>\nNow, without further ado, take it away Tim&hellip;\nDue to a recent physical site relocation, I was tasked with creating new conference rooms at our new location. By using Windows PowerShell, I initially created the common area phones in Microsoft Lync and assigned the applicable numbers to each. Here are the steps I followed:<\/p>\n<p style=\"padding-left: 30px\">&lt;#<\/p>\n<p style=\"padding-left: 30px\">.Synopsis<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Creating a Single New Lync Common Area Phone<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; You MUST run this on a Microsoft Lync server<\/p>\n<p style=\"padding-left: 30px\">.Description\nTo create a new Lync common area phone, you need the Number, Display Name, and Description, as shown in the following example:<\/p>\n<p style=\"padding-left: 30px\">.Example<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PS C:&gt; .New-CommonAreaPhone.ps1\nWhen you enter in phone number, such as &nbsp;(972) 555-0185, it will be converted for LineURI and DisplayNumber:<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Enter Display Name<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Enter Description<\/p>\n<p style=\"padding-left: 30px\">.Notes<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NAME: New-CommonAreaPhone.ps1<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VERSION: 3.1<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AUTHOR: Tim Bolton \/ Brian Peacock<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LASTEDIT: 09\/18\/2013<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p style=\"padding-left: 30px\">#&gt;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"># Create new common area phone, Enter new phone number, display name, and description.<\/p>\n<p style=\"padding-left: 30px\">Do {<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Phone=Read-Host &#8220;What is the New 10 digit Phone Number? &#8211; Example (972) 555-0185 &#8220;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } while ($Phone -match &#8220;^ddd-ddd-dddd$&#8221; -ne &#8220;True&#8221; )<\/p>\n<p style=\"padding-left: 30px\">Do {<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $DisplayName=Read-Host &#8220;What is the Display Name &#8211; Example Phone &#8211; BigDog &#8211; Executive Conf. Room 197 &#8220;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } while ($DisplayName.Length -le 5 )<\/p>\n<p style=\"padding-left: 30px\">Do {<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $Description=Read-Host &#8220;What is the Description &#8211; Example Something for the BigDog AD team &#8220;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } while ($Description.Length -le 5 )<\/p>\n<p style=\"padding-left: 30px\"># Converts the number for LineURI &amp; DisplayNumber<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $LineURI= &#8220;tel:+1&#8221; + $Phone.Replace(&#8220;-&#8220;, &#8220;&#8221;)<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [long]$Display=$Phone.Replace(&#8220;-&#8220;, &#8220;&#8221;)<\/p>\n<p style=\"padding-left: 30px\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $DisplayNumber=&#8221;{0:(###) ###-####}&#8221; -f $Display<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"># That generates the contact object in Active Directory. Give this about 60 seconds to bake before you run the following script against it.<\/p>\n<p style=\"padding-left: 60px\">New-CsCommonAreaPhone -LineUri $LineURI -RegistrarPool &#8220;BD-lyncpool.Big.Dog.Com&#8221; -DisplayName $DisplayName -DisplayNumber $DisplayNumber -Description $Description -OU &#8220;OU=Contacts,OU=Users,DC=Big,DC=Dog,DC=com&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"># Pause 60 Seconds for Lync Changes<\/p>\n<p style=\"padding-left: 60px\">write-host -foregroundcolor Green &#8220;Waiting for 60 Seconds Lync Changes to propogate&#8221;<\/p>\n<p style=\"padding-left: 60px\">Start-Sleep -s 60<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"># Then apply the PIN number and &nbsp;policies in order.<\/p>\n<p style=\"padding-left: 60px\">Write-Host -foregroundcolor Yellow &#8220;Configuring Lync Policies for $DisplayName &#8220;<\/p>\n<p style=\"padding-left: 60px\">Grant-CSPINPolicy -identity $DisplayName -PolicyName &#8220;commonareapin&#8221;<\/p>\n<p style=\"padding-left: 60px\">Grant-CsVoicePolicy -Identity $DisplayName -PolicyName &#8220;BigDog-National&#8221;<\/p>\n<p style=\"padding-left: 60px\">Grant-CsDialPlan -Identity $DisplayName -PolicyName &#8220;BigDogPlace&#8221;<\/p>\n<p style=\"padding-left: 60px\">Grant-CsConferencingPolicy&nbsp; -Identity $DisplayName -PolicyName &#8220;commonareaconferencing&#8221;<\/p>\n<p style=\"padding-left: 60px\">Grant-CsClientPolicy -Identity $DisplayName -PolicyName &#8220;commonareaclient-nohotdesking&#8221;<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\"># Pause 60 Seconds for Lync Policies<\/p>\n<p style=\"padding-left: 60px\">write-host -foregroundcolor Green &#8220;Waiting 30 Seconds Lync Policies to propogate&#8221;<\/p>\n<p style=\"padding-left: 60px\">Start-Sleep -s 30<\/p>\n<p style=\"padding-left: 60px\">Write-Host -foregroundcolor Yellow &#8220;Configuring Lync PIN for $DisplayName &#8220;<\/p>\n<p style=\"padding-left: 60px\">Set-CSClientPIN -identity $LineURI -pin 123456<\/p>\n<p style=\"padding-left: 60px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">#Verify the application of the Policies.<\/p>\n<p style=\"padding-left: 60px\">write-host -foregroundcolor Green &#8220;Completeing Tasks&#8221;<\/p>\n<p style=\"padding-left: 60px\">Start-Sleep -s 10<\/p>\n<p style=\"padding-left: 60px\">&nbsp;<\/p>\n<p style=\"padding-left: 60px\">Get-CsCommonAreaPhone &ndash;Identity $DisplayName<\/p>\n<p style=\"padding-left: 30px\">&nbsp;<\/p>\n<p style=\"padding-left: 30px\">Exit\nThe complete script is available in the Script Center Repository: <a href=\"http:\/\/gallery.technet.microsoft.com\/scriptcenter\/New-Lync-Common-Area-Phone-6abea4e4\">New Lync Common Area Phone<\/a>.\nAfter I created all of the phone numbers, I used a .csv file and Windows PowerShell to create the new conference rooms.&nbsp; This must be completed on an Exchange Server with proper Admin credentials or by remotely using PSSession to connect to an Exchange Server.\nThe .csv file headers consist of these known values:<\/p>\n<p style=\"padding-left: 30px\">Name, Alias, UserPrincipalName, Database, DisplayName, OrganizationalUnit, SamAccountName, RetentionPolicy, Notes, Description, Phone\nInitially, we wanted the rooms to be hidden so that users would not start booking the new conference rooms prior to them being available. To set the room to Hidden, I used the following script:<\/p>\n<p style=\"padding-left: 30px\">Write-Host -foregroundcolor Green &ldquo;Waiting 30 seconds for Replication Then will set Hidden From Exchange to $True!&rdquo;<\/p>\n<p style=\"padding-left: 30px\">Set-Mailbox -Identity $Entry.Alias -HiddenFromAddressListsEnabled $True\nAfter all of the conference rooms were created, we unhid them.\nThe default setting for the <strong>HiddenFromAddressListsEnabled<\/strong> property is <strong>$False<\/strong>, which is what I used when all of the rooms were available:<\/p>\n<p style=\"padding-left: 30px\">Set-Mailbox -Identity $Entry.Alias -HiddenFromAddressListsEnabled $False\n~Tim\nThank you, Tim, for another interesting and useful post. Join me tomorrow when I will talk about creating virtual adapters on Hyper-V. It will be cool.\nI invite you to follow me 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 email to me at <a href=\"http:\/\/blogs.technet.commailto: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, peace.\n<strong>Ed Wilson, Microsoft Scripting Guy<\/strong>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Guest blogger, Tim Bolton, discusses how he used Windows PowerShell to create a bunch of new conference rooms. Microsoft Scripting Guy, Ed Wilson, is here. Today we have another guest blog post by Tim Bolton. In one way, today&rsquo;s post is a continuation of the post we published on Friday about adding carriage returns [&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":[455,56,3,324,45],"class_list":["post-2760","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-csv","tag-guest-blogger","tag-scripting-guy","tag-tim-bolton","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Guest blogger, Tim Bolton, discusses how he used Windows PowerShell to create a bunch of new conference rooms. Microsoft Scripting Guy, Ed Wilson, is here. Today we have another guest blog post by Tim Bolton. In one way, today&rsquo;s post is a continuation of the post we published on Friday about adding carriage returns [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2760","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=2760"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/2760\/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=2760"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=2760"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=2760"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}