<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Lync PowerShell</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/csps/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/csps/feed.xml</link>
    <description />
    <lastBuildDate>Mon, 20 Apr 2015 09:02:49 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How To: Create a GUI Application with PowerShell</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/how-to-create-a-gui-application-with-powershell</link>
      <pubDate>Thu, 08 Dec 2011 11:05:02 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/12/08/how-to-create-a-gui-application-with-powershell/</guid>
      <description><![CDATA[&nbsp;
If you want to see an example of a GUI application created in Windows PowerShell, take a...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">If you want to see an example of a GUI application created in Windows PowerShell, take a look at the </span><a href="https://blogs.technet.com/b/csps/archive/2011/11/30/lyncdeleteomatic.aspx"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Lync Server Deleteomatic</span></a><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">. If you want to learn how to use PowerShell to create your own Deleteomatic, or any other type of GUI application, </span><a href="https://blogs.technet.com/b/csps/archive/2011/12/07/guiapp.aspx"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">read this article</span></a><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">. We&rsquo;ll take you through step-by-step.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">This article is for anyone working with Windows PowerShell. If you&rsquo;re not working with Lync Server, we&rsquo;ve pointed out where the Lync Server specific code is and you can easily replace it with any other .NET or PowerShell code.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><a href="https://blogs.technet.com/b/csps/archive/2011/12/07/guiapp.aspx"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">https://blogs.technet.com/b/csps/archive/2011/12/07/guiapp.aspx</span></a></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Creating Your Own GUI Application</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/creating-your-own-gui-application</link>
      <pubDate>Wed, 07 Dec 2011 14:17:00 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/12/07/creating-your-own-gui-application/</guid>
      <description><![CDATA[Creating Your Own GUI Application
(Cr&eacute;ation de Votre Propre Application...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 14pt;">Creating Your Own GUI Application</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 14pt;">(Cr&eacute;ation de Votre Propre Application GUI)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">This might come as a shock to many of you, but there was a time &ndash; a time long, <i>long</i> ago &ndash; when people didn't have cell phones. What could that even <i>mean</i> not to have cell phones? Well, for one thing, that meant that, if you left your house or your office, there might be a few minutes when people <i>wouldn't be able to get hold of you</i>! (Quelle horror!) If you had to run to the store you couldn't update your Facebook page while browsing through the produce section, and you couldn't read Ashton Kutcher's latest tweet while standing in the checkout line. You couldn't even call your wife to tell her, "I'm turning into the driveway right now." Zut alors!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. As you can see, the author of this article is taking an introductory French class. So what does "Zut alors!" mean? Well, if he knew that he wouldn&rsquo;t have to take introductory French, now would he?</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Shocking? You bet. But you know what's <i>really</i> shocking? Here's what really shocking: back in those days, hardly anyone ever moped around lamenting the fact that no one had invented cell phones yet. Because no one had ever seen a cell phone no one really gave the idea of having a portable phone a second thought. It wasn't until people actually <i>saw</i> a cell phone that they suddenly realized one thing: they couldn't <i>possibly</i> live without one.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">We mention this only because the same notion applies to things other than cell phones. For example, up until recently many of you might not have known that you can write GUI "applications" using Windows PowerShell; considering the fact that PowerShell is a command-line tool why <i>would</i> you know that? But now, having seen the </span><a href="https://blogs.technet.com/b/csps/archive/2011/11/30/lyncdeleteomatic.aspx"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Deleteomatic</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"> application created by the authors of the Lync Server PowerShell blog, you're probably thinking this: I can't <i>possibly</i> live without knowing how to create my own GUI application using Windows PowerShell.&nbsp; Fortunately for you, the authors of the Lync Server PowerShell blog are here.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Come to think of it, it <i>is</i> unusual to see the phrases "Fortunately for you" and "the authors of the Lync Server PowerShell blog are here" in the same sentence, isn't it? Tres bizarre!</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So how <i>do</i> you write a GUI "application" using Windows PowerShell? Good question, and one that we're going to try to answer for you. (Just don&rsquo;t expect the entire answer to come in this one article.) What we thought we would do is essentially walk you through the process of building your own Deleteomatic, or at least something vaguely similar to the Deleteomatic. We won't necessarily cover everything we did when creating the Deleteomatic, and we'll definitely go off on a few tangents every now and then in order to make a point. However, by the time we finish with this series you should be fully capable of sitting down and creating your very own Deleteomatic.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And, if not, well, hopefully by then someone will have written an app that will allow your cell phone to create a Deleteomatic for you. Either way you should be good to go.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif';">Step 1: Creating a Windows Form</span></b></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">To begin with, we should point out that there are no tricks involved here, nor do you need any special software or equipment to create the application we're going to create. In fact, all you really need is:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpFirst"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Windows PowerShell 2.0 (which you already have)</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Notepad, or any other text editor (which you also already have)</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpLast"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">A computer that has the Lync Server core components installed, or, at the least, a computer that can make a remote connection to a Lync Server computer and then import the Lync Server PowerShell module. Either way, you have to run the application on a computer that can run the Lync Server PowerShell cmdlets at the same time.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. We should probably clarify that you don't need Lync Server in order to create a GUI application using Windows PowerShell; all you really need is PowerShell and a text editor. However, if you want to create the application we're going to create in this series of articles, then you <i>will</i> need Lync Server. Why? That's easy: because this application is designed to help you manage Lync Server, and it can't do that unless it can access Lync Server. Make sense? </span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Or, as we French speakers like to say: un sens?</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">OK, technically you'll also need one other thing (which, again you already have): the .NET Framework. As it turns out, in order to create a GUI application using Windows PowerShell, we need to tap into the mysteries of the .NET Framework. Not that we're going to tap too deep: to be honest, we're not going to come anywhere <i>near</i> exploring all the different things you can do with the .NET Framework. That's more than we can cover in this series and a bit outside our area of expertise, to boot.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So then what <i>will</i> we do in this series? Things like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Set up the form ===========================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm = New-Object System.Windows.Forms.Form </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Text = "Microsoft Lync Server 2010 Practice Application"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Size = New-Object System.Drawing.Size(1200,800) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.StartPosition = "CenterScreen"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.KeyPreview = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What exactly <i>is</i> that? Well, that's Windows PowerShell code that creates a Windows form, the window where our GUI application will reside. What you need to do (if you're playing along at home) is copy that code exactly as-is, paste it into a text editor, and then save the code as a file with a .PS1 file extension (we saved ours as C:\Scripts\Practice.ps1). In other words:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/8561.gui_01.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/8561.gui_5F00_01.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/8561.gui_01.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/8561.gui_5F00_01.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what did we just save? Well, let's break that opening hunk of code down a bit. Ignoring the comment found in the first line of code, that hunk of code kicks off with these two lines:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">These two lines of code are used to load the .NET Framework classes we need in order to build a GUI application. &nbsp;Before you ask, yes, it's true: sometimes you have to explicitly load .NET classes using syntax like this, and sometimes you can use shortcuts that make the whole process a lot easier. (PowerShell is funny that way.) For example, this line of code creates a GUID using the .NET Framework, but without all that weird System.Reflection.Assembly stuff:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$x = [guid]::NewGuid()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Why do we sometimes have to use all that weird System.Reflection.Assembly stuff while other times we <i>don't</i> have to use it? Well, for this introductory article we aren't' going to worry about that. For now, let's just say that you need to use the two lines of code shown above in order to gain access to the System.Windows.Forms and the System.Drawing classes. As we get a little further down the road we'll delve a little deeper into .NET.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Probably.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">At any rate, that brings us to this block of code:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm = New-Object System.Windows.Forms.Form </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Text = "Microsoft Lync Server 2010 Practice Application"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Size = New-Object System.Drawing.Size(1200,800) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.StartPosition = "CenterScreen"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">This chunk of code is used to create and configure our window. In the first line, we use PowerShell's New-Object cmdlet to create a new instance of the System.Windows.Forms.Form class, an instance we store in an object reference named $objForm. (By the way, a lot of the things we do in order to create our GUI application will require us to create new objects that get stashed in object references.) After that we use the next few lines of code to modify property values of our new object. For example, in the second line we set the window caption (the Text property) to <i>Microsoft Lync Server 2010 Practice Application</i>, and in line 3, we set the size of our window: 1200 pixels wide by 800 pixels tall. Finally, we use line 4 to ensure that, when our application starts up, that application will be centered onscreen.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Got all that? Excellent. Now, copy that code into Notepad and save the file with a .PS1 file extension. At that point, we're ready to take this baby out for a spin. To do that, from within the Lync Server Management Shell (or from your remote instance of Windows PowerShell), type the full path to your script file and then press ENTER. For example:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">c:\scripts\practice.ps1</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what happened when we ran <i>our</i> script? Here's what happened:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6835.gui_02.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6835.gui_5F00_02.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6835.gui_02.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6835.gui_5F00_02.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">If you're thinking, "I don't get it; it doesn't look like <i>anything</i> happened," well, you're right: nothing <i>did</i> happen. Well, OK, technically the script <i>did</i> run, but nothing appeared on screen (let alone a GUI application). Why not? That's easy: as it turns out, simply creating a form isn't good enough. Instead, you actually have to <i>activate</i> the form and then explicitly tell PowerShell to display that form. If you don't, you'll get exactly what we got: nothing (rien).</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Fortunately, activating and displaying a form doesn't take much effort. All you have to do is copy these lines of code and paste them at the very bottom of your script:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Activate the form =========================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Add_Shown({$objForm.Activate()})</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objForm.ShowDialog()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Incidentally, when we say "the very bottom" we mean "the very bottom." (We apologize for this, but the best we can translate "the very bottom" as is "au fond," or, "at the bottom." Sorry.) These lines of code need to be the last lines in your script. That's important to keep in mind, because we're going to be adding a bunch of additional code to this script; when we do that, we have to make sure that all the code we add comes after our initial block of code (the code that creates the Windows form) but <i>before</i> the code that activates the form.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what happens <i>now</i> if we run our script? This happens:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/8081.gui_03.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/8081.gui_5F00_03.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/8081.gui_03.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/8081.gui_5F00_03.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Voil&aacute;: we have a GUI application!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">OK, sure, it might not be a <i>great</i> GUI application; after all, it doesn't really do much except show up on screen. (Although you could make an argument that software that doesn't do anything is sometimes preferable to what "real" pieces of software occasionally do.) But your point is well taken: who wants to spend their day laboring over stuff that doesn't do anything and that nobody even cares about?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Present company excepted, of course.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So let's see if we can get our application to actually <i>do</i> something. For starters, let's add a listbox to our application. Copy the following lines of code into your script, taking care to place these lines after the initial code block but before the code that activates and displays the form:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the listbox containing the Get-Cs cmdlets =============================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox = New-Object System.Windows.Forms.Listbox </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.Location = New-Object System.Drawing.Size(50,40) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.Size = New-Object System.Drawing.Size(260,320) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objCmdletsListbox)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">If you take a moment to glance at this code, it should be fairly obvious that the code is adding a new listbox to the form. (If nothing else, the comment, which starts off &ldquo;<i>Add the listbox</i>,&rdquo; should have given it away.) In line 1, we use the New-Object cmdlet to create a new instance of the System.Windows.Forms.Listbox class, storing this new instance in the variable $objCmdletsListbox. In line 2 we set the location for our listbox: 50 pixels from the left-hand side of our window and 40 pixels from the top of our window. In line 3, we configure the size of the listbox: 260 pixels wide by 320 pixels tall.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. So how did we <i>know</i> that we should make the listbox 260 pixels wide, and how did we <i>know</i> that the listbox should be 40 pixels from the top of our window? To be perfectly honest, we <i>didn't</i> know. We just started playing around with different numbers until we got what we wanted. You'll probably have to do the same sort of thing.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">By the way, don't forget to include the last line of code, the one that actually adds the listbox to the Controls collection for the form. What would we get if we forgot to add that line of code? Beats us. But one thing that we definitely <i>wouldn't</i> get is a listbox.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what's our application look like now? Well, assuming that we closed the original version of the application, modified our script, saved that modified script, and then restarted the application, we should now have something that looks like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2630.gui_04.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2630.gui_5F00_04.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2630.gui_04.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2630.gui_5F00_04.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">That's what we said: wow.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Actually, what we said was "sante fume!" which is French (sort of) for "holy smokes!" </span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">We see that, once again, you're not quite as impressed as we are. Granted, our application now has a listbox, but there's nothing <i>in</i> that listbox. And you're right: a listbox without data is like a day without sunshine.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Or pretty much like any day here in the Seattle area. (Currently 40 degrees and drizzling.)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">OK, fine. If you aren't impressed yet then let's see if we can add a little zing to our listbox. Let's try this: let's see if we can retrieve all the Lync Server <i>Get-Cs</i> cmdlets (Get-CsAddressBookConfiguration, Get-CsExternalAccessPolicy, Get-CsServerApplication, etc.) and then add those add those cmdlets to the listbox. Do we really think we can do that? Oui!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. French for "yes." In case you were wondering.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Here's what we're going to do: we're going to copy the following block of code and then paste that code immediately after the lines of code that created the listbox. Here's the block of code we're talking about: </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Invoke-Expression "Get-Command Get-Cs*"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; {&nbsp;&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [void] $objCmdletsListbox.Items.Add($item.Name)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; }</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Right now you're probably thinking, "Quelle est cette?" (What is this?) We'll tell you what this is: this is code that retrieves all the <i>Get-Cs</i> cmdlets and then adds those cmdlets to our listbox. Quelle horror!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Oh, wait; sorry. Quelle horror means "how horrible!" We should have said something like this: tres bien! (Very good!)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So how does this code do that? Well, to begin with, it uses the following command to retrieve all the <i>Get-Cs</i> cmdlets and stash the returned data in a variable named $items:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Invoke-Expression "Get-Command Get-Cs*"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Incidentally, that line of code gives us a chance to make an important point about working with GUI applications. As you know, if we were in the PowerShell console itself we could retrieve all the <i>Get-Cs</i> cmdlets (and store the returned data in a variable) by using a command like this one:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Get-Command Get-Cs*</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">But remember, we aren't in the PowerShell console: we're in our cool, new GUI application. Because of that, we can't call PowerShell commands like this one directly; instead, we need to pass those commands as strings and let Invoke-Expression call those commands. Why? Well, because &ndash; well, again, for now we aren't going to worry about the why part of this. Instead, it's just important to know that we have to take this approach whenever we call a PowerShell command: put the command into a string, then run the command (the string) using Invoke-Expression. For now, just trust us on that one.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">As difficult as that is to do.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So now that we have all the <i>Get-Cs</i> cmdlets safely stashed away in the variable $items what do we <i>do</i> with these cmdlets? That's what these lines of code are for:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; {&nbsp;&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [void] $objCmdletsListbox.Items.Add($item.Name)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; }</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What we've done here is set up a foreach loop that loops through each cmdlet stored in the variable $items. And what do we do each time through the loop? Well, each time through the loop we use this line of code to add the cmdlet Name to our listbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objCmdletsListbox.Items.Add($item.Name)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">See how that works? A listbox has an Items property, the Items property has a method named Add. All we have to do is tell the Add method what we want to add: in this case, that's the cmdlet Name. What if we didn't want to put cmdlet Names in our listbox but, instead, we wanted to put French color names in that box? In that case, we'd just use a series of commands similar to these:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objCmdletsListbox.Items.Add("blanc")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objCmdletsListbox.Items.Add("noir")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objCmdletsListbox.Items.Add("rouge")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objCmdletsListbox.Items.Add("vert")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Etc., etc.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Good question: what <i>is</i> that [void] thing for? Well, if we haven't made this clear yet, our GUI "application" is really just a PowerShell script. The script has to be called from PowerShell and PowerShell must be running if you want your script to run: if PowerShell should terminate unexpectedly then your script is going to terminate unexpectedly as well. (Fin &hellip; uh, well, terminate unexpectedly.) In other word, you'll always have a PowerShell window running alongside your GUI application. </span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what does that have to do with the [void] thing? Well, if you leave off the [void] thing you'll get a whole bunch of junk written to the PowerShell window. It's not a big deal and it doesn't hurt anything, but it's not very elegant. And the authors of the PowerShell blog are nothing if not elegant (&eacute;l&eacute;gante).</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So, once again, let's close our application, modify our code, save the changes, and then re-run the script. Puis? (And then)? Et puis cette: (And then this):</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1256.gui_05.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1256.gui_5F00_05.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1256.gui_05.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1256.gui_5F00_05.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Not bad, eh? (Pas mal, eh?) Granted, you might not be <i>terribly</i> impressed, but take a minute to think about what we've done here. Using nothing fancier than Notepad and a few PowerShell commands, we've created an application that pops up in a real, live window. As if that wasn't cool enough, we've added a standard Windows user interface control to that window (the listbox) and then, by calling out to Windows PowerShell and running a Lync Server PowerShell cmdlet, we've managed to populate that listbox with real, live data. All things considered, that's definitely <i>not</i> bad, not bad at all.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">But we've hardly begun to scratch the surface of what we can do here. For example, let's see if we can turn this up a notch and maybe get our little application to do something semi-useful. (Something our managers have been trying to do with us for several years now.) Here's what we're going to do: we're going to add a <i>second</i> listbox to our application! (That's right: zut alors!) Copy this code and paste it after the code we used to populate our first listbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the Instances listbox&nbsp; ================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox = New-Object System.Windows.Forms.Listbox </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Location = New-Object System.Drawing.Size(50,400) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Size = New-Object System.Drawing.Size(260,200) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objInstancesListbox) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Because you're now an old hand at creating listboxes we won't bother explaining what this block of code does. Instead, let's just save the script and re-run it. When we do that, our application should look something like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2260.gui_06.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2260.gui_5F00_06.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2260.gui_06.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2260.gui_5F00_06.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Just like we said: two listboxes in a <i>single</i> application!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Again, that's pretty cool in and of itself. But you know what would be even <i>cooler</i>? That's right: what would be even cooler is if we could populate this second listbox with some data, too. Fortunately enough, we just happened to have some code that does that very thing:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the subroutine for retrieving instances ===============================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.Add_Click(</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; {</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $items = Invoke-Expression "$cmdlet | Select-Object Identity"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $objInstancesListbox.Items.Clear()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;if ($items &ndash;ne $Null)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;{</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;{&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[void] $objInstancesListbox.Items.Add($item.Identity)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;}</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;}</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; })</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So is this just your plain old, every day, fill-a-listbox-with-data code? Hardly. What we have here is a subroutine that specifies the actions that should take place when someone clicks on our first listbox. How do we <i>know</i> that this subroutine specifies the actions that should take place when someone clicks on our first listbox? Well, as you might recall, when we created that first listbox we also created an object reference named $objCmdletsListbox. As you can see, we're using that object reference when defining our subroutine; in fact, what we're doing is adding the Click method (Add_Click) to the listbox referenced by $objCmdletsListbox. What's the point of that? Here's the point of that: this method tells our application what to do any time someone clicks in the listbox containing our list of cmdlets. </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Are there <i>other</i> methods that we could add to a listbox? Sure; take a peek at the <b><a href="https://msdn.microsoft.com/en-us/library/system.windows.forms.listbox.aspx">official listbox documentation</a></b> on MSDN for more information.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And just what <i>is</i> our application going to do when someone clicks in that listbox? The first thing it's going to do is figure out which item in the listbox was actually clicked; that's what this line of code (and the SelectedItem property) is for:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">As you know, our listbox is filled with cmdlet names. That means that $cmdlet will contain a cmdlet name. For example, if we clicked on <b>Get-CsExternalAccessPolicy</b> then $cmdlet will be equal to <i>Get-CsExternalAccessPolicy</i>. If we click on <b>Get-CsAdDomain</b> then cmdlet will be equal to <i>Get-CsAdDomain</i>. If we &ndash; well, you get the idea.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So does any of that really matter to us? Well, it will in a moment. Take a look at the next line of code:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Invoke-Expression "$cmdlet | Select-Object Identity"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What we've done here is constructed another Lync Server PowerShell command and then used Invoke-Expression to call that command. If $cmdlet is equal to <i>Get-CsExternalAccessPolicy</i> then that means we've constructed, and then executed, this command:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Get-CsExternalAccessPolicy | Select-Object Identity</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">In other words, we clicked on <b>Get-CsExternalAccessPolicy</b> and, in response, our application has just run that very same cmdlet (Get-CsExternalAccessPolicy), returned the Identity of each our external access policies, and then stashed those Identities in the variable $items.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And yes, that <i>is</i> kind of nifty, isn't it?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">But the next part is even niftier. What we're going to do next is take those policy Identities and display them in our second listbox; in other words, when you click a cmdlet in the first listbox, all the instances returned by that cmdlet are displayed in the second listbox. (You'll see a visual explanation of that in just a second.) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Before we do that, however, we need to clear any existing items out of listbox No. 2; that's what this line of code is for:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Items.Clear()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And then we use this foreach loop to methodically add each policy Identity to the listbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; if ($items &ndash;ne $Null)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; {</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [void] $objInstancesListbox.Items.Add($item.Identity)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Don't forget to close your subroutine with these two lines of code:</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; })</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Oh, and why did we check to see if $items is equal to a null value ($Null)? You're way ahead of us: if our cmdlet didn't return any instances then there's no reason to try to put those non-existent instances into our listbox. It's not going to work.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what does all <i>that</i> give us? Well, after we save and restart the script, and if we then click on Get-CsExternalAccessPolicy, we should now see something like this: </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3000.gui_07.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3000.gui_5F00_07.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3000.gui_07.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3000.gui_5F00_07.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">As you can see, in our little test deployment of Lync Server we have two external access policies: Global, and Tag:RedmondExternalAccess. See, we <i>told</i> you this would be cool, didn't we?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">But before we get too carried away with congratulating ourselves, and before our arms get too tired from patting ourselves on the back, let's issue one caveat. (Which kind of sounds like a French word, but actually comes from the Latin word <i>cavere</i>, or "let him beware.") Our application is going to work just fine for most of the <i>Get-Cs</i> cmdlets. How do we know that? We know that because most of the <i>Get-Cs</i> cmdlets will work without you specifying a particular item to be retrieved. For example, do you want information on all your external access policies? Then run this command in the Lync Server Management Shell:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsExternalAccessPolicy</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What about information for all your analog devices? The run this command:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsAnalogDevice</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">However, (and, unfortunately), there are some exceptions. For example, try running this command:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsRgsConfiguration</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Is that going to return all your Response Group configuration settings? Sadly, no, it's not. Instead, it's going to prompt you for the Identity of the settings to be returned:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">cmdlet Get-CsRgsConfiguration at command pipeline position 1</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Supply values for the following parameters:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Identity: </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Is that a problem? Well, not if you're working in the PowerShell console; you just answer the prompt and get on with your life. But if you're working in our little application, yes, it <i>is</i> a problem. This prompt isn't going to appear in the application, it's going to appear in the PowerShell console. Even worse, your application is going to get all hung up, because it can't run Get-CsRgsConfiguration until it knows which Identity to use. </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Now, there are things we can do to guard against this problem, but in this initial article we aren't going to worry about those things; instead, we're just going to warn you not to click on cmdlets like Get-CsRgsConfiguration. You should also avoid clicking these cmdlets:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpFirst"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsAdContact</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsAdminRoleAssignment</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsAdUser</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsClientCertificate</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsClientPinInfo</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsUICulture</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsUser</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsUserAcp</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpLast"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Get-CsUserPoolInfo</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. OK, admittedly, some of these cmdlets, like Get-CsAdUser, don't require an Identity. However, if you have a really big deployment, and a whole <i>bunch</i> of users, they could take forever to run. For now, it's best to avoid them.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what happens if you ignore all our warnings (as if people were going to suddenly start taking our advice) and click Get-CsRgsConfiguration anyway? Well, in that case, we recommend that you go back to the PowerShell console and press Ctrl+C to kill the current command. (You might have to do that several times to finally kill the command.) When Ctrl+C finally takes effect you should then see an error message similar to this one:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/4520.gui_08.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/4520.gui_5F00_08.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/4520.gui_08.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/4520.gui_5F00_08.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Click the Continue button to dismiss the error message, then close and restart your GUI application. That <i>should</i> take care of the problem. If it doesn't, you'll probably have to terminate and restart PowerShell. It's kind of a hassle but, hey, this <i>is</i> version 1 of our application. And since when has version 1 of <i>any</i> product from Microsoft ever worked?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Uh, you should probably forget we ever said that. We're in enough trouble these days as it is.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Originally that was all we were going to do for this first article. When we got this far, however, we realize that we didn't want to end on such a gloomy note, what with all this talk of killing commands and unhandled exceptions. With that in mind, let's jazz this thing just a little more. First, let's toss in some code that adds a text box to our form:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add a text box to the form&nbsp; ===============================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox = New-Object System.Windows.Forms.TextBox</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Location = New-Object System.Drawing.Size(680,40) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Size = New-Object System.Drawing.Size(460,500) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Multiline = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Font = New-Object System.Drawing.Font("Courier New", "8.5")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Wordwrap = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.ReadOnly = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.ScrollBars = [System.Windows.Forms.ScrollBars]::Vertical</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objOutputBox)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">That's going to give us a form that looks like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/4544.gui_09.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/4544.gui_5F00_09.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/4544.gui_09.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/4544.gui_5F00_09.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. And to think that there are people who don't believe Microsoft is capable of creating a beautiful, well-conceived user interface!</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Our next step &ndash; as you might have guessed &ndash; is to now try and display some data in that brand-new textbox. What we've decided to do is this: when you click an item in our second listbox (the one that displays things like our external access policies) we want all the properties of the clicked item (for example, the Global external access policy) to appear in the textbox. Are we even <i>capable</i> of pulling off such a feat? Probably not. But that's never stopped us before:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the subroutine for retrieving instance values =========================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Add_Click(&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; { </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;$cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $instance = $objInstancesListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $objOutputBox.Text = Invoke-Expression `</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;"($Cmdlet -Identity $instance | Format-List | Out-String).Trim()"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; })</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What we've done here is add a subroutine to the instances listbox ($objInstancesListbox); this subroutine is going to tell our application what to do if someone clicks a specific instance of a policy or configuration setting. And what <i>is</i> our application going to do? Well, first it's going to grab the cmdlet name from the first (cmdlets) listbox; that way, it knows which cmdlet it needs to use:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Next, it's going to grab the Identity from the second (instances) listbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$instance = $objInstancesListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And once the application knows both the cmdlet name and the instance Identity it can then construct a command, run that command, and write the output to the textbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Text = Invoke-Expression `</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; "($Cmdlet -Identity $instance | Format-List | Out-String).Trim()"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">That's kind of a complicated-looking command, so let's explain just exactly what it's doing, and why it's doing that. The first part is actually pretty easy: it's just using the selected <i>Get-Cs</i> cmdlet to return the selected instance:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$Cmdlet -Identity $instance</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><br />We next take the data that comes back and pipe it to the Format-List cmdlet; Format-List will then display the data as a list rather than a table. Does that matter? In some cases, no: typically the data <i>will</i> be displayed as a list anyway. However, that might not be the case when we start to add even <i>more</i> bells and whistles to this application; when we do that, PowerShell might try to display some of our data as a table. Because we have limited space within our text box we don't really <i>want</i> data displayed as a table. If we pipe everything to Format-List we don't have to worry about that.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">If we look at our entire command it looks like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">($Cmdlet -Identity $instance | Format-List | Out-String).Trim()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Why do we return the data, format it as a list, and then pipe it to the Out-String cmdlet? That's easy: if you grab PowerShell data from within an application like this and then try to display that data as-is in a textbox this is what you get:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Microsoft.PowerShell.Commands.Internal.Format.FormatStartData Microsoft.PowerShell.Commands.Internal.Format.GroupStartData Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData Microsoft.PowerShell.Commands.Internal.Format.GroupEndData Microsoft.PowerShell.Commands.Internal.Format.FormatEndData</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">Cute, but not all that useful.&nbsp; The only way to work around that problem (or at least the only way that we know of) is to pipe the data to the Out-String cmdlet, which converts that weird object information to string values. And then, just to make the output a little nicer-looking, we use the Trim() method to delete any blank lines or blank spaces that might appear at the beginning or the end of that output.</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">So what's the net result of all that work? This:</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7367.gui_10.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7367.gui_5F00_10.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7367.gui_10.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7367.gui_5F00_10.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Pretty slick, huh? Jolie &hellip; slick &hellip;.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">OK, that <i>is</i> all we're going to do today. But don't worry: we'll back soon with the next installment in the series. What will we cover in <i>that</i> installment? Well, we're not really sure at the moment: to tell you the truth, our articles typically come as more of a surprise to us than they probably do to you.&nbsp; But you can bet (pretty much, anyway) that we'll show you how to make our GUI application even better, and even fancier.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Until then, all we can say is this: &agrave; bient&ocirc;t! (See you later!)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Yes, that literally <i>is</i> all we can say. We really should do our homework more often.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Oh, there <i>is</i> one last thing: here's the complete code for all the work we did today, just in case you have any questions about what was supposed to go where. Enjoy!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Set up the form ===========================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm = New-Object System.Windows.Forms.Form </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Text = "Microsoft Lync Server 2010 Practice Application"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Size = New-Object System.Drawing.Size(1200,800) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.StartPosition = "CenterScreen"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the listbox containing the Get-Cs cmdlets =============================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox = New-Object System.Windows.Forms.Listbox </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.Location = New-Object System.Drawing.Size(50,40) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.Size = New-Object System.Drawing.Size(260,320) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$items = Invoke-Expression "Get-Command Get-Cs*"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; {&nbsp;&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; [void] $objCmdletsListbox.Items.Add($item.Name)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; }</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objCmdletsListbox) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the Instances listbox&nbsp; ================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox = New-Object System.Windows.Forms.Listbox </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Location = New-Object System.Drawing.Size(50,400) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Size = New-Object System.Drawing.Size(260,200) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objInstancesListbox) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the subroutine for retrieving instances ===============================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objCmdletsListbox.add_Click(</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; {</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $items = Invoke-Expression "$cmdlet | Select-Object Identity"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $objInstancesListbox.Items.Clear()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;if ($items &ndash;ne $Null)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;{</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;foreach ($item in $items)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [void] $objInstancesListbox.Items.Add($item.Identity)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;}</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; })</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add a text box to the form&nbsp; ===============================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox = New-Object System.Windows.Forms.TextBox</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Location = New-Object System.Drawing.Size(680,40) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Size = New-Object System.Drawing.Size(460,500) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Multiline = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Font = New-Object System.Drawing.Font("Courier New", "8.5")</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.Wordwrap = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.ReadOnly = $True</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objOutputBox.ScrollBars = [System.Windows.Forms.ScrollBars]::Vertical</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Controls.Add($objOutputBox)</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Add the subroutine for retrieving instance values =========================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objInstancesListbox.Add_Click(&nbsp; </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; { </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $cmdlet = $objCmdletsListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $instance = $objInstancesListbox.SelectedItem</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp; $objOutputBox.Text = Invoke-Expression `</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; "($Cmdlet -Identity $instance | Format-List | Out-String).Trim()"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp; }) </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;"># Activate the form =========================================================</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">$objForm.Add_Shown({$objForm.Activate()})</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[void] $objForm.ShowDialog()</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>The Deleteomatic</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/the-deleteomatic</link>
      <pubDate>Wed, 30 Nov 2011 14:02:15 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/11/30/the-deleteomatic/</guid>
      <description><![CDATA[&nbsp;
It slices, it dices, it purees, it&hellip;well, no, it doesn&rsquo;t actually do any of...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">It slices, it dices, it purees, it&hellip;well, no, it doesn&rsquo;t actually do any of those things. What it <i>does</i> is delete, and what it <i>is</i> is the Lync Server Deleteomatic. We&rsquo;ve create a graphical user interface with PowerShell that you can use to delete objects, such as policies and configuration settings, from Lync Server.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">This is a handy little utility, but make sure you read the disclaimer. This isn&rsquo;t a fully-tested and fully-supported (or even partially-supported) utility. All it really is is a demonstration of creating a GUI interface for your Lync Server PowerShell commands. Take a look, play around with it, <a href="mailto:cspshell@microsoft.com">send us your feedback</a> if you have any. In <a href="https://blogs.technet.com/b/csps/archive/2011/11/30/lyncdeleteomatic.aspx">this article</a> we explain what the Deleteomatic does. In future articles we&rsquo;ll explain <i>how</i> the Deleteomatic does what it does.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><a href="https://blogs.technet.com/b/csps/archive/2011/11/30/lyncdeleteomatic.aspx">https://blogs.technet.com/b/csps/archive/2011/11/30/lyncdeleteomatic.aspx</a></span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>The Lync Server Deleteomatic</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/the-lync-server-deleteomatic</link>
      <pubDate>Wed, 30 Nov 2011 11:10:00 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/11/30/the-lync-server-deleteomatic/</guid>
      <description><![CDATA[Have Fun and Delete Things, Too:
The All-New Lync Server Deleteomatic
&nbsp;
&nbsp;
Between...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 14pt;">Have Fun and Delete Things, Too:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 14pt;">The All-New Lync Server Deleteomatic</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Between the Lync Server Management Shell, the Lync Server Control Panel, and all the assorted Lync Server Resource Kit tools you're probably thinking, "You know, I already have all the Lync Server management tools I could ever need." But guess what? If you <i>are</i> thinking that you already have the Lync Server management tools you could ever need that can mean only one thing: you haven't heard about the Deleteomatic yet.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">The Whatomatic? </span></b></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">The <i>Deleteomatic</i>. The Deleteomatic is a little PowerShell script (well, OK, not <i>that</i> little; it does have more than 600 lines) that's designed to delete things. (Hence the clever name.) More specifically, the Deleteomatic is designed to delete Lync Server things, things like client policies, dial plans, Address Book configuration settings, Response Group queues, and &ndash; well, you get the idea. With one or two exceptions, if it can be deleted from Lync Server then the Deleteomatic can delete it. </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. And yes, as a matter of fact, it <i>does</i> slice, dice, and make </span><a href="https://www.smithsonianlegacies.si.edu/objectdescription.cfm?ID=224"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">julienned fries</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">! </span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">It just doesn't do any of those things very well.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Ah, that's a good question: can't you just use the Lync Server Management Shell and/or the Lync Server Control Panel to delete things from Lync Server? Of course you can; for that matter, there are probably all sorts of other tools that you can use to delete things from Lync Server. However, as incredibly useful as the Management Shell and the Control Panel are, the truth of matter is that both of these tools <i>do</i> have a few limitations. (For one thing, just try making julienne fries with the Control Panel and you'll soon see what we mean.) In addition to that:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpFirst"><span style="font-family: Symbol;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Not everything that can be deleted from Lync Server can be deleted by using the Control Panel; for example, Address Book settings can't be found anywhere in the Control Panel. Admittedly, you <i>can</i> pretty much delete everything that's deletable by using the Management Shell; if you couldn't, the Deleteomatic (which relies on Lync Server PowerShell) wouldn't work. At the same time, however, using the Management Shell sometimes requires you to deal with &hellip; interesting &hellip; commands like this one: <br /><br /></span><span style="font-family: 'Courier New'; font-size: 10pt;">Remove-CsRgsAgentGroup -Identity service:ApplicationServer:atl-cs-001.litwareinc.com/1987d3c2-4544-489d-bbe3-59f79f530a83</span><br /><br /><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And yes, there <i>are</i> ways to work around the need to use Identities like the one shown above. But even then, typing commands from the Management Shell prompt will always require you to, well, type commands at the Management Shell prompt. And typing things is often-times easier said than dnoe. <br /><br />Er, <i>done</i>.<br /><br /></span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">The Control Panel only allows you to delete one item at a time. Again, you <i>can</i> delete multiple items using the Management Shell, but even then you can only do that if those items fit a well-defined pattern. (For example, all the client policies configured at the per-user scope.) But supposed you wanted to delete the DublinClientPolicy, the RedmondClientPolicy, and the site:Redmond policies, and delete them all in one fell swoop? Can you do <i>that</i> with the Management Shell? No, you cannot.<br /><br />Well, OK, so maybe you <i>can</i>. But it's not especially intuitive how you would go about doing it.<br /><br />And no, we're not going to give you a hint on how you <i>would</i> do that; if we did, you wouldn't need the Deleteomatic, now would you? But here's a hint on how you can do that:<br /><br /></span><span style="font-family: 'Courier New'; font-size: 10pt;">"DublinClientPolicy","RedmondClientPolicy","site:Redmond" | Remove-CsClientPolicy<br /></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><br />That works. But, again, it <i>is</i> a lot of typign. <br /><br />Er, <i>typing</i>.<br /><br /></span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpMiddle"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">One of the golden rules of Lync Server management is this: it's never a good idea to delete a per-user policy without first unassigning that policy from any users who have been assigned that policy in the first place. Can you do <i>that</i> using either the Management Shell or the Control Panel? You bet you can. However, you're on your own to figure out how to unassign and <i>then</i> remove that per-user policy.<br /><br />And this time we mean it. (OK, fine: later in this article we'll show you code that does that.)<br /><br /></span></p>
<p style="line-height: normal; text-indent: -0.25in; margin-bottom: 0pt;" class="MsoListParagraphCxSpLast"><span style="font-family: Symbol; font-size: 10pt;">&middot;<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Neither the Management Shell nor the Control Panel provides an obvious way to back something up before it gets deleted. As a general rule, that doesn't matter: after all, if you're planning on deleting something that's usually because you don't want the thing anymore anyway. And yet, still, there <i>is</i> that whole notion of being better safe than sorry. In other words, there might be times when it would be a good idea to make a backup copy of your Address Book configuration settings before you delete those settings. However, with no Backup command in the Control Panel, and with no Backup-CsAddressBookConfiguration cmdlet, well, that, too is much easier said than done.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Fortunately, though, the Deleteomatic has been designed to address all these issues, and more. For example, with the Deleteomatic you can delete multiple items at once, and without having to know the item's Identity. (Instead, the Deleteomatic will <i>show</i> you the Identity; you don't have to have all your Identities memorized.) If you choose to delete a per-user policy then the Deleteomatic will automatically unassign that policy before deleting it. And, if you want to, you can even ask the Deleteomatic to make a backup copy of something before that something gets deleted. Needless to say, it's the greatest Lync Server tool ever!</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Official Disclaimer</span></b></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Having said that, you should not consider the Deleteomatic to be the greatest Lync Server tool ever; in fact, you shouldn't even consider the Deleteomatic to be a Lync Server tool, period. The Deleteomatic came about because we wanted to show people how to write GUI "applications" using Windows PowerShell. (If we haven&rsquo;t made it clear yet, the Deleteomatic is written entirely in Windows PowerShell.) When we first came up the idea of showing people how to add GUI elements to their scripts, we thought we'd just demonstrate how you could do something simple like, say, display a window that shows a list of all your client policies or something. However, that seemed a bit lame.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Yes, even for us.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Because of that, we started adding features to our sample script and, before we knew it, we had a Deleteomatic on our hands. (Very similar to the process Michelangelo underwent when he just started painting over a couple marks on a wall and then somehow ended up with the ceiling of the Sistine Chapel.) All of these additional features are nice, and they make the Deleteomatic look like a real application. Keep in mind, however, that the Deleteomatic is, at heart, just a demonstration of how you can write GUI "applications" using Windows PowerShell. The Deleteomatic is intended to show you the kinds of things that <i>you</i> can do using Windows PowerShell and the Lync Serve cmdlets. As such, it's not a real Microsoft application, it's <i>not</i> a supported utility, it's largely untested, it will never be localized into other languages, and we can't say with 100% certainty that, if you use the Deleteomatic, all your hair won't immediately fall out.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Which might explain why one of authors of the Deleteomatic always wears a baseball hat. Hey, you never know, right?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Good point: if the Deleteomatic is just a way to demonstrate the sorts of things that you can do with Windows PowerShell and the Lync Server cmdlets, shouldn't we have an article that explains the code <i>behind</i> the Deleteomatic? Well, for once at least, we're way ahead of you. </span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">But enough about that. Let's see if we can figure out what the Deleteomatic does and how it actually does it.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Yes, considering the fact that we wrote the Deleteomatic we <i>should</i> be able to figure out what it does and how it actually does it. But we learned a long time ago never to take anything for granted, especially anything that we happen to be involved in.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So Where Can I Buy One of These Deleteomatics?</span></b></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Well, you can't: the Deleteomatic is not for sale. However, what you <i>can</i> do is get a free copy of the thing instead: all you need to do is grab a copy of the ZIP file Deletomatic.zip (located at the end of this article) and then extract Deleteomatic.ps1 to a folder of your choice (for example, C:\Scripts). </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Got that? Perfect. Next, start up the Lync Server Management Shell. (Or, if you prefer, start a remote session of Windows PowerShell and import the Lync Server module.) As soon as the Management Shell is up and running, type the full path to your script file and then press ENTER. In our case, that would mean typing the following at the PowerShell prompt:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">C:\Scripts\Deleteomatic.ps1</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">With any luck, the Deleteomatic will soon appear in all its glory:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6254.lyncdo001.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6254.lyncdo001.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6254.lyncdo001.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6254.lyncdo001.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And you're right: that <i>doesn't</i> look like much, does it? But just wait until you see it in action.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">The Deleteomatic in Action</span></b></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">To begin with, take a peek at the upper left-hand portion of the screen. What you'll see there is a list of all the <i>Remove-Cs</i> cmdlets:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2134.lyncdo002.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2134.lyncdo002.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2134.lyncdo002.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2134.lyncdo002.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. OK, what we should say is that you'll see <i>most</i> of the <i>Remove-Cs</i> cmdlets. As a general rule, you'll see all the <i>Remove-Cs</i> cmdlets that use an Identity parameter. However; there <i>are</i> a few Lync Server cmdlets that don't use an Identity parameter. (Case in point? Most of the <i>Remove-CsLis</i> cmdlets, the cmdlets used with the Location Information Service, don&rsquo;t use an Identity parameter.) In order to make our life easier, and in order to keep the Deleteomatic code as simple as possible, we decided to leave out cmdlets that don't play by the rules.</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Or at least cmdlets that don't include an Identity parameter. But we'll talk more about that in the articles that talk about the Deleteomatic code.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what are you supposed to do with that list of <i>Remove-Cs </i>cmdlets? We'd suggest you do this: click on a cmdlet of interest. For example, click on the Remove-CsConferencingPolicy cmdlet:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1067.lyncdo003.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1067.lyncdo003.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1067.lyncdo003.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1067.lyncdo003.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">When you do that, two things are going happen. (Three, if you count the feeling of peace and tranquility that will likely sweep over your body.) First, you should see a brief description of the cmdlet and what it does:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/5280.lyncdo004.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/5280.lyncdo004.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/5280.lyncdo004.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/5280.lyncdo004.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">More important, you should also see a list of all your existing conferencing policies:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7356.lyncdo005.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7356.lyncdo005.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7356.lyncdo005.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7356.lyncdo005.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Why is this list of existing policies important? That's easy. Thanks to this list, the Deleteomatic can now do what it was born to do: delete things.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. What if you don't <i>have</i> any existing conferencing policies? Well, to tell you the truth, that's impossible: at the very least, you'll always have a global conferencing policy. However, it <i>is</i> possible to click on a cmdlet &ndash; like, say, Remove-CsRgsAgentGroup &ndash; only to discover that you don't have any Response Group agent groups. But that's OK. All that means is that nothing will show up in the <b>Available Instances</b> listbox, and that there won't be anything for the Deleteomatic to delete. It kind of takes the fun out of using the Deleteomatic, but it doesn't hurt anything.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So did you click on the Remove-CsConferencingPolicy cmdlet like we suggested? Excellent. Now, go ahead and click one of your existing conferencing policies; when you do that, the Deleteomatic should light up like a Christmas tree:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3036.lyncdo006.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3036.lyncdo006.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3036.lyncdo006.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3036.lyncdo006.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. OK, not like a particularly <i>nice</i> Christmas tree; it's really more of a </span><a href="https://yourholidaywallpaper.com/images/wmwallpapers/Charlie-Brown-Tree-1.jpeg"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Charlie Brown</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"> kind of Christmas tree. But a Christmas tree nonetheless.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So what exactly <i>is</i> all this information that has suddenly festooned the Deleteomatic? Well, on the right-hand side of the screen you'll see all the property values for the selected policy:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6170.lyncdo007.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6170.lyncdo007.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6170.lyncdo007.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6170.lyncdo007.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Why does the Deleteomatic show you all the property values for the selected item? You got it: because that way you'll know exactly what it is you're deleting before you actually delete it.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">We thought that was kind of handy, too. And guess what? One of the cool things about the Deleteomatic is that it lets you select (and then, if you want to, to delete) <i>multiple</i> items. For example, suppose you click one conferencing policy, then hold down the <b>Ctrl</b> key and click a second conferencing policy. That means the selected instances will look like this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1805.lyncdo008.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1805.lyncdo008.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/1805.lyncdo008.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/1805.lyncdo008.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">On top of that, property values for <i>both</i> of the selected policies will show up in the <b>Property Values</b> box:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7268.lyncdo009.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7268.lyncdo009.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/7268.lyncdo009.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/7268.lyncdo009.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Could there be <i>anything</i> better than that? No. That's as good as life will ever get.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Sorry to have to be the ones to break that to you.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">We're the first to admit that working with multiple items is pretty exciting; for now, though, let's go back to our original scenario, the one where we selected only a single conferencing policy (TestPolicy). When we do that, we should also see the following code in the <b>Script Code</b> box:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3554.lyncdo010.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3554.lyncdo010.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/3554.lyncdo010.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/3554.lyncdo010.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What's <i>that</i> code for? As it turns out, that's the code that deletes the selected policy.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And yes, we know what you're thinking: that <i>does</i> look like a lot of code just to delete one little conferencing policy, doesn't it? Because of that, let's take a moment to explain <i>why</i> there's so much code there.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">For starters, we have this little block of PowerShell coding:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsUser -Filter {ConferencingPolicy -eq "Tag:TestPolicy"} |&nbsp; Grant-CsConferencingPolicy -PolicyName $Null</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What this code does is unassign the selected policy (TestPolicy) from any users who have been assigned the policy (and it does this <i>before</i> the policy is deleted). What's the point of that? Well, as you probably know, if you try to delete a per-user policy and that policy is currently assigned to one or more users, you're going to be presented with a confirmation prompt similar to this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">The policy "TestPolicy" is currently assigned to one or more users. Assign a different policy to the users before removing this one.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">The policy is in use.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">[Y] Yes&nbsp; [N] No&nbsp; [S] Suspend&nbsp; [?] Help (default is "Y"):</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">If you answer yes (Y), you can go ahead and remove the policy without first unassigning it from the affected users; Lync Server has no problem with you doing that. However, from that point on any time you do <i>anything</i> that involves user accounts and Lync Server PowerShell (even a simple thing, like listing the display names of all your users) you'll get annoying little warnings like this in your output:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">DisplayName</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">-----------</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Pilar Ackerman</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Patrick Hines</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; color: red; font-size: 10pt;">WARNING: "TestPolicy" with identity "14" assigned to "sip:kenmyer@litwareinc.com" has been removed from configuration store.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Ken Myer</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Ann Reagan</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">These warnings aren't fatal, and they don't cause any real problems. But they <i>can</i> be annoying.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. You say this has already happened to you? Or, more correctly, to a &hellip; friend &hellip; of yours? Bummer. But don't despair; our article </span><a href="https://blogs.technet.com/b/csps/archive/2011/02/10/howtoremovepolicies.aspx"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Getting Rid of Policies You Thought You Already Got Rid Of</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"> should help you get rid of those unwanted warnings.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">At any rate, code like the following unassigns a per-user policy before the Deleteomatic actually deletes that policy:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsUser -Filter {ConferencingPolicy -eq "Tag:TestPolicy"} |&nbsp; Grant-CsConferencingPolicy -PolicyName $Null</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">We should also note that you'll see a block of code like that only when you're dealing with a per-user policy; if you're dealing with a global, site, or service policy, or if you're dealing with a collection of configuration settings you won't see that code:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/5611.lyncdo011.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/5611.lyncdo011.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/5611.lyncdo011.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/5611.lyncdo011.png" /></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Why don't you see code for unassigning the policy? We know why: because those other items (like a global policy or like configuration settings) are never directly assigned to users. You don't have to worry about unassigning something that was never assigned to begin with. </span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. Good question: <i>has</i> anyone ever been assigned the selected per-user policy in the first place? Beats us. But the Deleteomatic will also show you the total number of users currently assigned a policy:</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2084.lyncdo012.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2084.lyncdo012.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2084.lyncdo012.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2084.lyncdo012.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Just something we decided to throw in when the Deleteomatic kept burning the fries instead of julienning them. </span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">So does all that make sense? Let's hope so, because now we're moving on to our next chunk of code:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Remove-CsConferencingPolicy -Identity "Tag:TestPolicy" -Confirm:$False -ErrorVariable Err -ErrorAction SilentlyContinue</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Believe it or not, that's the code that actually deletes the TestPolicy policy. Again, you're probably wondering, "Why is there so <i>much</i> code?" After all, wouldn't this little bit of code work equally well:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Remove-CsConferencingPolicy -Identity "Tag:TestPolicy"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">In this case, yes, that little snippet of code <i>would</i> work equally well. However, some of the <i>Remove-Cs</i> cmdlets prompt you before you actually delete something. That's fine, except that this prompt appears in the Management Shell window instead of in the Deleteomatic. There are probably all sorts of ways that we could try to trap that prompt and display in the Deleteomatic window instead. To be honest, though, that was too much trouble; we wanted to keep the Deleteomatic as simple as we could. (And we didn&rsquo;t want to put <i>too</i> much work into the thing considering the fact that this was just a little side project and has nothing at all to do with our <i>real</i> work.) Therefore, we took the easy way out and added this bit of code to each command in order to suppress the confirmation prompt:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">-Confirm:$False</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Admittedly, you don't always <i>need</i> to do this: most of the <i>Remove-Cs</i> cmdlets don't have a confirmation prompt anyway. But, again, it was easier to just tack this on to every command rather than sit down and try to figure out which commands actually needed it and which ones didn't.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Then there's little addition to each command:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">-ErrorVariable Err -ErrorAction SilentlyContinue</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">This code is there on the off-chance that something goes wrong when you try to delete an item. For example, suppose you try to delete a policy and, for some reason (maybe another administrator has just deleted it), that policy can't be deleted. Without the preceding code, the error message received would appear in the Management Shell window; that means you might never <i>see</i> the message. All we're doing here is capturing the error message so it can be displayed in the Deleteomatic; that's what the ErrorVariable parameter is for. Meanwhile, the ErrorAction parameter tells PowerShell to keep chugging away even if an error <i>does</i> occur. In turn, that means the Deleteomatic will not get hung up if, say, a particular policy can't be deleted.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">OK. Let's assume that we will really <i>do</i> want to delete the TestPolicy conferencing policy. How do we do that? By clicking the <b>Run Script</b> button, of course:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/0250.lyncdo013.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/0250.lyncdo013.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/0250.lyncdo013.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/0250.lyncdo013.png" /></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Do that and the Deleteomatic will run all the code in the <b>Script Code</b> box. In the example we've been using, that means the Deleteomatic will unassign TestPolicy from any users who were previously assigned that policy and then remove TestPolicy from the system.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Just that easy, just that quick.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Two notes about the <b>Run Script</b> button. First, why do we even <i>have</i> a <b>Run Script</b> button; couldn't we just delete an item the moment you clicked on that item in the <b>Available Instances</b> box? Yes, we could. But that would mean that you could only delete items one-by-one. It would also mean that you could never make a mistake; after all, if you accidentally clicked on the wrong policy the Deleteomatic would go ahead and delete that policy. Based on our own personal experience, we decided it was best not to assume that a mistake would never be made.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Second, yes, you <i>can</i> modify the code in the <b>Run Script</b> box, and the Deleteomatic will dutifully run whatever code appears in there. We're not sure that's a great idea: for one thing, it sort of defeats the whole purpose of the Deleteomatic. For another, we can't guarantee what will happen if you type something <i>really</i> crazy into the <b>Run Script</b> box. But suppose you type this in the box and then click <b>Run Script:</b></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New'; font-size: 10pt;">Get-CsDialPlan</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">In turn, information about your dial plans will be displayed in the Deleteomatic:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2018.lyncdo014.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2018.lyncdo014.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2018.lyncdo014.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2018.lyncdo014.png" /></a></span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Kind of a weird thing to do, yes. But it works.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Just a few more notes and then we'll call it a day. Some of you might have noticed the <b>Save Code</b> and the <b>Save Output</b> buttons in the Deleteomatic user interface:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/0250.lyncdo013.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/0250.lyncdo013.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/0250.lyncdo013.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/0250.lyncdo013.png" /></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"></span>&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">The <b>Save Code</b> button does exactly what the name suggests: it saves the current code to the default folder. (That's the path listed in the text box labeled <b>Save Output and Script Code to This Folder</b>.) Want to turn the code generated by the Deleteomatic into a regular old .ps1 script file? Then just click the <b>Save Code</b> button.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">As for <b>Save Output</b>, clicking that button simply saves the data displayed in the <b>Property Values</b> box. So, yes, if you wanted to you could use the Deleteomatic to retrieve information and then save that information to a text file. Click a cmdlet, click an instance (or instances), and then, instead of deleting those instances, click <b>Save Output</b> to save the information.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Consider that another little bonus that we threw in, just for the heck of it.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And then there's this:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6646.lyncdo015.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6646.lyncdo015.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6646.lyncdo015.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6646.lyncdo015.png" /></a></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What's the <b>Backup before deleting</b> checkbox for? Well, to begin with, if you select this checkbox you'll end up with <i>another </i>little hunk of code in the <b>Script Code</b> box:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2043.lyncdo016.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2043.lyncdo016.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/2043.lyncdo016.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/2043.lyncdo016.png" /></a>&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">In other words:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal">&nbsp;</p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Courier New';">Get-CsConferencingPolicy -Identity "Tag:TestPolicy" | Export-Clixml -Path "C:\Scripts\Lyncomatic\CsConferencingPolicy_Tag-TestPolicy.xml"</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What this command does is make a copy of the selected item (or items) in XML format; in turn, that gives you a sort of backup copy of the selected item. And <i>that</i> gives you a way to restore the item should you later regret deleting it.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<div style="padding-bottom: 1pt; padding-left: 4pt; padding-right: 4pt; background: #ffffcc; padding-top: 1pt; border: windowtext 1pt solid;">
<p style="line-height: normal; margin-bottom: 0pt; background: #ffffcc; padding: 0in;" class="MsoNormal"><b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Note</span></b><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">. With some limitations. See the article </span><a href="https://blogs.technet.com/b/csps/archive/2011/02/28/howtobackuppolicies.aspx"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">How to Undo That Thing You Wish You Had Never Done in the First Place</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"> for more information.</span></p>
</div>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Finally, we should point out that the Deleteomatic is actually a fairly dynamic little application. For example, suppose we select the conferencing policy TestPolicy and then click <b>Run Script</b>. As soon as the policy has been removed, the Deleteomatic will automatically update the <b>Available Instances</b> listbox:</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6175.lyncdo017.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6175.lyncdo017.png"><img style="max-width: 550px;" border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/83/62/articles/Deleteomatic/6175.lyncdo017.png" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-83-62-articles-Deleteomatic/6175.lyncdo017.png" /></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">What more could you ask for?</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">Oh. Well, that <i>would</i> be a nice addition, wouldn't it? And so would that. Tell you what: if you have suggestions for or run into problems with the Deleteomatic, drop us a line at </span><a href="mailto:cspshell@microsoft.com"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">cspshell@microsoft.com</span></a><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;"> and we'll see what can do. In the meantime, enjoy version 1.0, and keep your eye for our upcoming series of articles that explain how you can write your own Deleteomatic.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">And no, sorry: we have no plans for a series explaining <i>why</i> you might want to write your own Deleteomatic. You're on your own there.</span></p>
<p style="line-height: normal; margin-bottom: 0pt;" class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 10pt;">&nbsp;</span></p>
</div>
<p><a href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/8362/00/00/03/46/81/67/deleteomatic.zip" original-url="https://blogs.technet.com/cfs-filesystemfile.ashx/__key/telligent-evolution-components-attachments/01-8362-00-00-03-46-81-67/deleteomatic.zip">deleteomatic.zip</a></p>]]></content:encoded>
    </item>
    <item>
      <title>Interested in Working for the Lync Server Team?</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/interested-in-working-for-the-lync-server-team</link>
      <pubDate>Mon, 21 Nov 2011 09:52:48 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/11/21/interested-in-working-for-the-lync-server-team/</guid>
      <description><![CDATA[OK, so if you could have your absolute dream job, what would it be?
&nbsp;
Wow, that really...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">OK, so if you could have your absolute <i>dream</i> job, what would it be?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Wow, that really <i>would</i> be a great job, wouldn't it? Listen, if you decide not to apply for that, could you let us know? Thanks!</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Let's rephrase our original question: if you couldn't get your absolute dream job then what job <i>would</i> you like to have? That's the answer we were looking for: you'd want to work for the Microsoft Lync Server team, the same team that produces, well, Microsoft Lync Server. Of course, who <i>wouldn't</i> want to work for the Lync Server team, who <i>wouldn't</i> want the chance to help produce the next version of the coolest, most-innovative piece of software on the planet? (Or <i>planets</i>, for that matter: we don't think they have anything on Mars that compares with Lync Server.) But let's be honest: what are the odds that you could get the chance to work on the Lync Server team? After all, a high-powered team like the Lync Server team probably doesn't even advertise when it has open positions; instead, it probably goes around the world and handpicks only the best and the brightest.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Present company excepted, of course.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Amazing enough, however, that's <i>not</i> how Lync Server does things: not only do we advertise our open positions, but at this very moment we're advertising <i>three</i> open positions! If all goes well, that means that you really <i>could</i> come work for the Lync Server team.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Which, in all seriousness, would be <i>way</i> cool.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So what three positions do we have available? For starters, the manageability team (the team that, among other things, is responsible for Lync Server's implementation of Windows PowerShell) is looking for a pair of software development engineers. Those engineers will help to "&hellip; build the tools used to keep the service running, automatically reimage and redeploy servers, and manage a complex global deployment from a single console." If that's not a dream job, well, we don't know what is.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Of course, there <i>is</i> a catch: qualified applicants " &hellip; need to write reliable, readable, rock-solid code in C#, PowerShell, SQL and C++, and interface with WDS, AD, numerous SQL servers, Windows Workflow, Azure and many more." Wow. But if that sounds like you, and you think you might be interested, you can find more information about the two positions here:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-top: 0in; margin-right: 0in; margin-bottom: .0001pt; margin-left: .5in; text-indent: -.25in;"><span style="font-size: 11.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=16&amp;jid=53300&amp;jlang=EN"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';">https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=16&amp;jid=53300&amp;jlang=EN</span></a></p>
<p style="margin-top: 0in; margin-right: 0in; margin-bottom: .0001pt; margin-left: .5in; text-indent: -.25in;"><span style="font-size: 11.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=15&amp;jid=64381&amp;jlang=EN"><span style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';">https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=15&amp;jid=64381&amp;jlang=EN</span></a></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. If these jobs are so great then why haven't the authors of the PowerShell blog snapped them up? Perhaps you missed this part: qualified applicants must " &hellip; write reliable, readable, rock-solid code in C#, PowerShell, SQL and C++, and interface with WDS, AD, numerous SQL servers, Windows Workflow, Azure and many more." In other words, to work on the Lync Server team, you actually need to know what you're doing.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Present company excepted, of course.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">If software development isn't your thing then maybe you'd be interested in our third opening: Software Engineer II. If you're wondering what a Software Engineer II does, well, a Software Engineer II helps to " &hellip; support Service Deployment, Activation, Administration, Troubleshooting, Root Cause Analysis, User Management, Monitoring and Optimization." If you like getting your hands dirty, and if you'd like to <i>really</i> know how Lync Server works, then <i>this</i> is the job for you.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And yes, as a matter of fact you <i>do</i> need to be qualified to do this job, too; among other things, this position "&hellip; requires strong technical knowledge and advance skills in ADFS, LDAP, ADSI, Kerberos/ NTLM / Certificate authentication, PowerShell Scripting, DNS, SIP, TCP/IP, and other network protocols."&nbsp; If you have those skills, well, we can't think of a more interesting, and more challenging, environment in which to put those skills to the test.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">You say you'd like more information on this position? All you had to do was ask:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=1&amp;jid=65564&amp;jlang=EN"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">https://careers.microsoft.com/JobDetails.aspx?ss=&amp;pg=0&amp;so=&amp;rw=1&amp;jid=65564&amp;jlang=EN</span></a></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">We strongly encourage everyone to take a look at the job postings and see what you think; if you think "Wow, I would <i>love</i> to have this job," well, you can apply right online. (Just get a fresh copy of your resume our and then click the button that's somewhat-mysteriously labeled <b>Apply to job</b>.) If you'd like more information about the positions then drop us a note at </span><a href="mailto:cspshell@microsoft.com"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';" lang="EN">cspshell@microsoft.com</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';" lang="EN">. We can't promise that we'll be able to answer every question, but we'll do our best. And on your first day of work here, we'll take you out for a cup of coffee, on us!</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';" lang="EN">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';" lang="EN">What do you mean "And a doughnut?" Tell you what: get the job first, and then we'll go from there.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';"></span>&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';"></span>&nbsp;</p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';"></span>&nbsp;</p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Download the Lync Server Admin Guide PowerShell Supplement</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/download-the-lync-server-admin-guide-powershell-supplement</link>
      <pubDate>Thu, 20 Oct 2011 08:46:02 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/10/20/download-the-lync-server-admin-guide-powershell-supplement/</guid>
      <description><![CDATA[Some of the writers on the Lync PowerShell blog have been accused at times of not being very...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Some of the writers on the Lync PowerShell blog have been accused at times of not being very good listeners. And when we say &ldquo;some&rdquo; of the writers we mean one of the writers has been accused of that &ndash; mostly by the other writer. But today we both decided to listen. Not to each other, of course, but to you, our devoted readers.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">In July we posted the <a href="https://blogs.technet.com/b/csps/archive/2011/07/13/adminguidepssupplement.aspx">Lync Server Administration Guide: PowerShell Supplement</a> to this blog. We did this because the Lync Server Administration Guide, although a very useful thing to have, didn&rsquo;t have a lot of PowerShell in it. So we decided to show you how you can do all the things in the Admin Guide by using PowerShell. And people seemed to appreciate that. But here&rsquo;s where the listening came in: As nice as it is to have this supplemental information posted on a blog, we were told it would be even nicer to provide it in one nice, neat, downloadable document. We agreed, which is why you can now <b><a href="https://www.microsoft.com/download/en/details.aspx?displaylang=en&amp;id=13161">download the Lync Server Administration Guide: PowerShell Supplement</a></b> as a Microsoft Word document.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Did we hear applause out there somewhere? See, our hearing is getting better all the time. (We&rsquo;re still working on the listening.)</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Lync Server PowerShell September 2011 Wrap-Up</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/lync-server-powershell-september-2011-wrap-up</link>
      <pubDate>Fri, 30 Sep 2011 09:26:44 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/09/30/lync-server-powershell-september-2011-wrap-up/</guid>
      <description><![CDATA[&nbsp;
&nbsp;
For those of you who were following our Haiku of the Day, you know that the...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';"></span>&nbsp;</p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">For those of you who were following our Haiku of the Day, you know that the haiku writer spent a month hiking and biking around Park City, Utah. Now that he&rsquo;s back, he has absolutely nothing to say and so has stopped writing the daily haiku.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Okay, that&rsquo;s not entirely true. He did stop writing the daily haiku, but only because he ran out of Lync Server cmdlet nouns. Will the Haiku of the Day begin again if and when Lync Server releases new cmdlets? Well, we&rsquo;ll have to think about that one. It depends on whether anything interesting is going on in the haiku writer&rsquo;s life at the time. (Which makes the prospect doubtful.)</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">In the meantime, haikus for all the cmdlets that shipped with Lync Server 2010 are available to you in the </span><a href="https://blogs.technet.com/b/csps/p/haikuarchive.aspx"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Haiku Archive</span></a><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><b><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Tip of the Month</span></b></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Need help with using a Lync PowerShell cmdlet? Of course, you can always type Get-Help at the command prompt, like this:</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Courier New';">Get-Help New-CsVoicePolicy &ndash;Full</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">But this is the help that originally shipped with the product. We&rsquo;ve made a few updates since then. If you want the most up-to-date help available, you need to go to the web. Here&rsquo;s an easy way to do that:</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Courier New';">Get-Help New-CsVoicePolicy &ndash;Online</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Assuming you have an Internet connection, this command takes you straight to the updated help on TechNet for the cmdlet of your choice (in this case, New-CsVoicePolicy).</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><b><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">What Happened at the Lync Server PowerShell Blog in September</span></b></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">To be honest, very little happened in the blog in September. About all we did was post haikus for the final 13 Lync Server cmdlet nouns:</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<table style="border-collapse: collapse;" class="MsoTableGrid" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/01/haiku182.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsStaticRoutingConfiguration</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/02/haiku183.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsDatabase</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/06/haiku184.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsUserAcp</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/07/haiku185.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsOutboundTranslationRule</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/08/haiku186.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsVoiceConfiguration</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/12/haiku187.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsClientVersionPolicyRule</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/13/haiku188.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsCertificateConfiguration</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/14/haiku189.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsTrustedApplicationComputer</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/15/haiku190.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsRgsWorkflow</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/16/haiku191.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsClientPolicy</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/19/haiku192.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsVoiceRoute</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/20/haiku193.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsDeviceUpdateRule</span></a></p>
</td>
</tr>
<tr style="height: 15.0pt;">
<td style="width: 216.5pt; padding: 0in 5.4pt 0in 5.4pt; height: 15.0pt;" valign="top" width="289">
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.5pt; font-family: Symbol; color: #333333;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><a href="https://blogs.technet.com/b/csps/archive/2011/09/21/haiku194.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsCertificate</span></a></p>
</td>
</tr>
</tbody>
</table>
<p class="MsoNormal"><span style="font-size: 10.5pt; line-height: 115%; font-family: 'Segoe UI','sans-serif'; color: #333333;">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><b><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">From the Community</span></b></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Here are some things from elsewhere in the Windows PowerShell and Lync Server world:</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><a href="https://blogs.technet.com/b/akshat/archive/2011/07/26/automatically-enable-users-in-a-particular-ou-for-lync-2010.aspx"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">Automatically enable users in a particular OU for Lync 2010</span></a></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">From Akshat N, a blog post the presents a &ldquo;quick and dirty way&rdquo; to schedule a task that will automatically Lync-enable any users in an OU who have not yet been enabled.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><a href="https://tfl09.blogspot.com/2011/09/powershell-v3-and-updateable-help.html"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">PowerShell V3 and Updateable Help</span></a></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">If you haven&rsquo;t taken a peek at what&rsquo;s happening with Windows PowerShell v3, here&rsquo;s an interesting little feature discussed on Thomas Lee&rsquo;s blog. This doesn&rsquo;t have anything to do with Lync Server 2010, but it never hurts to see what&rsquo;s going on in the world of PowerShell in general.</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt;" class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Haiku #194</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/haiku-194</link>
      <pubDate>Wed, 21 Sep 2011 09:54:02 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/09/21/haiku-194/</guid>
      <description><![CDATA[Turn out the lights, the
Party's over: today's our
Last haiku (for now). 
&nbsp;
Today is a...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Turn out the lights, the</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Party's over: today's our</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Last haiku (for now). </span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Today is a very auspicious, and somewhat sad, occasion: it marks, for the moment anyway, the end of the Lync Server PowerShell Haiku of the Day. (Trust us, <i>we</i> thought this day would never come, either.) Believe it or not, by the time today's haiku is finished we'll have worked our way through all the Lync Server PowerShell nouns. In turn, that means we can't have any more haikus, at least not until we have some more Lync Server PowerShell nouns to work with.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. <i>Will</i> there be more Lync Server PowerShell nouns in the near future? Well, we're not allowed to talk about future Lync Server plans, simply because no one ever fills us in on future Lync Server plans. But let's just say that we haven't thrown away our haiku-writing hat, not just yet.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So what does this all mean for the Lync Server PowerShell blog? Well, to be honest, we're not totally sure about that. We'll continue to post articles to the blog, and we'll continue to keep you as up-to-date as possible on Lync Server PowerShell. But what it actually means to "keep you as up-to-date as possible" is still to be determined. Why? Well, for one thing, now that we're done writing haikus, our managers think maybe it might be time for us to do some <i>real</i> work.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. But don't worry: they'll change their mind once they see what happens when we <i>do</i> try to do some real work.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But hey, we'll worry about tomorrow come tomorrow. As for today, we thought we'd spend a large portion of our time reviewing some of the great moments and happy memories from the Lync Server PowerShell Haiku of the Day:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraph"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">OK, well, apparently there aren't quite as many great moments and happy memories as we thought. (But hey, we'll always have the story of </span><a href="https://blogs.technet.com/b/csps/archive/2011/03/22/haiku072.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Planet Nibiru</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, right?) With that in mind, there's only one thing left to do: talk about the CsCertificate cmdlets (</span><a href="https://technet.microsoft.com/en-us/library/gg398227.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Get-CsCertificate</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg398688.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Import-CsCertificate</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg412895.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Remove-CsCertificate</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg425723.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Request-CsCertificate</span></a>, and <a href="https://technet.microsoft.com/en-us/library/gg398518.aspx">Set-<span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">CsCertificate</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">).</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Before we begin we should probably note that we aren't exactly experts when it comes to certificates, let alone Lync Server certificates. (What's that? But we <i>were</i> experts on all the other topics we covered in our previous haikus? Well, maybe not <i>experts</i>, mind you &hellip;.) We'll try to give you an overview of what the CsCertificate cmdlets do, but if you're thinking, "I should ask these guys if it's a good idea to use wildcards in my SANs," well, then you should probably think a little harder.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But hey, give us a break: after all, we <i>are</i> haiku writers. Would you ask </span><a href="https://en.wikipedia.org/wiki/Masaoka_Shiki"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Masaoka Shiki</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';"> if it's a good idea to use wildcards in your SANs?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Although even <i>he'd</i> probably know more about that than we would.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Masaoka Shiki was a famous Japanese poet and is acknowledged as one of the 4 great haiku masters. (Shouldn't that be <i>5</i> great haiku masters? Well, modesty prevents us from saying anything about that.) Here's a sample haiku from Masaoka Shiki:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">getting a shave!</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">on a day when Ueno's bell</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">is blurred by haze...</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So yes, obviously he <i>does</i> know more about certificates than we do. But, then again, who doesn't?</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">We thought we'd kick things off by talking a little bit about the Request-CsCertificate cmdlet. Request-CsCertificate is actually a remarkably clever cmdlet: you simply tell Request-CsCertificate that you need a certificate, and it does a lot of the work involved in figuring out what kind of certificate you need and how to configure that certificate. For example, suppose you request a WebServicesExternal certificate. If you do that, request-CsCertificate will read your topology and automatically add the Simple URLs for meet and dialin (as well as your reverse proxy URL) to the Subject Alternative Name field. What's that? You say there's also a <i>third</i> Simple URL: admin? Yes, there is. But typically you don't want to expose your admin URL to the outside world. And Request-CsCertificate is smart enough to know that.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Like we implied earlier, certificates can be a &hellip; challenge &hellip; to work with. Because of that, we won't run through all the different parameters available when running Request-CsCertificate; we could start a whole new haiku series just on those. (But don't worry: we <i>won't</i> start a whole new haiku series on Request-CsCertificate parameters.) Instead, we'll just give you an idea of what a command asking for a new certificate might look like:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Request-CsCertificate -New -Type Default,WebServicesInternal,WebServicesExternal -ComputerFqdn "atl-cs-001.litwareinc.com" -CA "atl-ca-001.litwareinc.com\myca" -FriendlyName "Enterprise Edition Pool Certificate" -Template jcila -PrivateKeyExportable $True -DomainName "pool1.litwareinc.com,pool1int.litwareinc.com,pool1ext.litwareinc.com"</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Like we said, this <i>can</i> be a bit of a challenge.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. On the bright side, Lync Server's Certificate Wizard actually uses Request-CsCertificate when it comes time to ask for a new certificate. Because of that, and because no one wants to do <i>that</i> much typing, you might consider just using the Wizard to request new certificates. The Wizard is a bit more user-friendly, but you'll still get to take advantage of all the cleverness built into Request-CsCertificate.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">When you use Request-CsCertificate (or the Certificate Wizard) to make an online request for a new certificate, that new certificate will be retrieved and will automatically be available to use with Lync Server. But what if you make an offline request, or what if you have certificates that <i>weren't</i> obtained using Request-CsCertificate? That's fine; if you have certificates that were acquired without using Request-CsCertificate (or the Certificate Wizard) you can still use those certificates with Lync Server. All you have to do is use the Import-CsCertificate wizard to, for all intents and purposes, let Lync Server know that the certificate exists:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Import-CsCertificate -Path "C:\Certificates\WebServer.cer" -PrivateKeyExportable $True</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And after the certificate has been imported, you can then use Set-CsCertificate to assign that certificate to a Lync Server server or server role:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Set-CsCertificate -Type WebServicesExternal -Thumbprint "B142918E463981A76503828BB1278391B716280987B"</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">What did we tell you? Certificates can be a challenge, but the CsCertificate cmdlets are anything but a challenge.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That leaves just two cmdlets to talk about: Remove-CsCertificate and Get-CsCertificate. As you might expect, Remove-CsCertificate removes a Lync Server certificate. Except, to be a bit more accurate, it doesn't really <i>remove</i> the certificate: the certificate will remain on your computer and can be used for other purposes. Instead, Remove-CsCertificate simply marks the certificate as no longer being available for use by Lync Server, removes any certificate bindings, and revokes access permissions to the certificate. The certificate will still exist, but Lync server won&rsquo;t know that: if you run the Get-CsCertificate cmdlet that certificate will not show up.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Speaking of which, now might be as good a time as any to mention that Get-CsCertificate returns information about your Lync Server certificates. (And only your Lync Server certificates: if a certificate wasn't obtained using Lync Server or wasn't imported using Lync Server, well, then Get-CsCertificate won't return information about that certificate.) You say you want to see information about all your Lync Server certificates? Then just run this command:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsCertificate</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Want information about just the Default certificate? Then use <i>this</i> command:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsCertificate &ndash;Type Default</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">How about all the certificates that <i>don't</i> include <i>sip.fabrikam.com</i> in the AlternativeNames property? Sure; why not:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsCertificate&nbsp; | Where-Object {$_.AlternativeNames -notcontains "sip.fabrikam.com"}</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Etc., etc.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">The only drawback to the Get-CsCertificate cmdlet is that it only returns certificates from the local computer. You say you need certificate information from a remote computer? Then you're either going to have to log on to that remote computer or connect to it using remote PowerShell in order to get that data.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But, then again, nobody's perfect right? With the possible exception of Masaoka Shiki, of course. </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. After all, not only did Masaoka Shiki save the ancient art of haiku writing, but he's also a member of the Japanese Baseball Hall of Fame. For comparison purposes, Wade Boggs is in the Major League Baseball Hall of Fame, but did <i>he</i> help save the ancient art of haiku writing?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Well, OK, maybe Wade Boggs did. But we're pretty sure that Walter "Big Train" Johnson <i>didn't</i>.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That's pretty much all we have to say about the CsCertificate cmdlets. Typically we sign off each day by saying "See you tomorrow," not because that was a clever way to sign off but simply because we could never actually come <i>up</i> with a clever way to sign off. But now that the daily haiku series is done for a while, we can't just end things by saying "See you tomorrow." So, we'll just end things.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Haiku #193</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/haiku-193</link>
      <pubDate>Tue, 20 Sep 2011 10:22:20 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/09/20/haiku-193/</guid>
      <description><![CDATA[If a tree falls in
The forest then it's his fault.
Device update rules. 
&nbsp;
Here's...]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">If a tree falls in</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">The forest then it's </span></i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">his<i> fault.</i></span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Device update rules. </span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Here's something that will shock you: the author of today's haiku is a cold-blooded killer.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Really? OK. We just <i>thought</i> that would shock you.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">As it turns out, yesterday the author of today's haiku printed out a one-page checklist of things he needs to look into for an upcoming documentation project. When he went to pick up his one page (front and back) checklist, the cover sheet attached to the printout included this blood-curdling message:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">You just killed a tree</span></b></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">As you might expect, the author of today's haiku was stunned to hear that he had just killed a tree. After all, the author of today's haiku has always fancied himself something of a conservationist, and has always been a dedicated recycler. For example, back when his son used to get action figures for Christmas, the author of today's haiku would dutifully tear apart the packaging for those action figures, tossing out the plastic, but recycling the cardboard. For someone like that to kill a tree, well, that wasn't exactly the best news he got all day.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. OK, actually that <i>was</i> the best news he got all day. But that's another story.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So how can the author of today's haiku defend himself? Well, truthfully, he can't: after all, he <i>did</i> click the <b>Print</b> button. Still, he <i>did</i> only use up a single piece of paper (the same amount of paper required for the cover sheet). And he <i>does</i> wonder this: if it takes an entire tree to make one piece of paper, shouldn't we maybe look for a different paper supplier? But no excuses: what's done is done.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">To make matters even worse, this isn't the first time he's been accused of killing trees. Every month when he gets his bill from the cable company, that bill includes a memo noting that he could have saved a tree by switching to electronic billing. That bill also includes a <i>ton</i> of advertisements for other services the cable company offers but that the author of today's haiku has yet to sign up for. The bill also includes flyers for the cable company's on-demand service (because the author of today's haiku is likely to be thinking, "I <i>demand</i> to see <i>Shark 3D</i>, right now!) and for upcoming pay-per-view extravaganzas like <i>WrestleMania</i>&nbsp; (can you believe we're up to <i>WrestleMania XVII </i>already; where does the time <i>go</i>?) and the next UFC championship bout (Quinton "Rampage" Jackson vs. Anne Hathaway). The author of today's haiku isn't trying to justify the fact that he killed a tree by not switching to electronic billing; he's just wondering how many trees the cable company killed by including all that wasted paper in his bill?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Ah, good point: maybe the cable company <i>is</i> holding him (or, more correctly, the trees) hostage. "Switch to electronic billing now or we start killing the hostages one-by-one." </span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And no, the author of today's haiku would never put <i>anything</i> past the cable company.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But enough about that. By now you're probably wondering, "So what does the author of today's haiku do when he <i>isn't</i> singlehandedly deforesting the world?" And here's your answer: he uses the CsDeviceUpdateRule cmdlets (</span><a href="https://technet.microsoft.com/en-us/library/gg398949.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Approve-CsDeviceUpdateRule</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg398215.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Get-CsDeviceUpdateRule</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg425930.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Remove-CsDeviceDeviceRule</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg398181.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Reset-CsDeviceUpdateRule</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, and </span><a href="https://technet.microsoft.com/en-us/library/gg398305.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Restore-CsDeviceUpdateRule</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">) to manage the device update service.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Hey, even cold-blooded killers need to have a hobby, right?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So what's so great about the CsDeviceUpdateRule cmdlets? Two things. First, they're environmentally-friendly: even the author of today's haiku rarely kills a tree when running these cmdlets. (Hey, we said <i>rarely</i>.) Perhaps more important, they serve a very useful function when it comes to managing Microsoft Lync Server 2010.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And what <i>is</i> that useful function? Well, as you know (because you <i>did</i> read </span><a href="https://blogs.technet.com/b/csps/archive/2011/07/05/haiku145.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Haiku #145</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, didn't you?) Lync Server uses the device update service to provide a way to push firmware updates to devices that run Microsoft Lync Phone Edition. These firmware updates are periodically published by Microsoft, and administrators can easily get a copy of the updates and then upload the update files to Lync Server. From there, the updates can then be distributed to the appropriate phones and devices.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">You know, that's a good point: there <i>have</i> been times when updates have created more problems than they solved, haven't there? But don't worry: the Lync Server product team already thought of that. When you upload your device update "rules" (a rule is simply an update for a particular type of device, such as LG-Nortel cell phones) each rule is marked as being in a Pending state. When a rule is marked as <i>Pending</i>, that means it does <i>not</i> get pushed out to all the relevant devices. Instead, the update is only installed on predefined </span><a href="https://blogs.technet.com/b/csps/archive/2011/02/04/haiku040.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">test devices</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. After administrators have verified that the update is working properly on the test devices <i>then</i> the update rule can be marked as being Approved. That update will then be automatically downloaded and installed on all the relevant devices (for example, all the LG-Nortel cell phones).</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So how does a device update rule get approved? Why, by calling the Approve-CsDeviceUpdateRule cmdlet, of course:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Approve-CsDeviceUpdateRule -Identity service:WebServer:atl-cs-001.litwareinc.com/d5ce3c10-2588-420a-82ac-dc2d9b1222ff9</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Admittedly, that's an &hellip; interesting &hellip; little command. (Please don't print it out; the author of today's haiku has killed enough trees as it is.) The problem, as you can see, is that each device update rule has an Identity that consists of the Web server the rule was imported to plus a GUID (globally unique identifier). That makes it easy to uniquely pinpoint a given rule, but somewhat <i>less</i> easy to actually type in a command that approves that rule.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But don't despair: with clever use of the Get-CsDeviceUpdateRule cmdlet you can typically avoid having to work with rule Identities. For example, suppose you have only one update rule that refers to LG-Nortel phones. Perfect; that means you can use a command like this to retrieve (and approve) that rule:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsDeviceUpdateRule | Where-Object {$_.Brand -eq "LG-Nortel"} | Approve-CsDeviceUpdateRule</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That's a little bit easier, to say the least. And if you need to get a little fancier (say you only want to approve a specific model of the LG-Nortel phone), well, then just get a little fancier:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsDeviceUpdateRule | Where-Object {$_.Brand -eq "LG-Nortel" &ndash;and $_.Model &ndash;eq "IP8540"} | Approve-CsDeviceUpdateRule</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">With the Get-CsDeviceUpdateRule cmdlet you can filter on such things as:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpFirst"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Device type (typically UCPhone)</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Brand</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Model</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Revision</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Locale</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">UpdateType</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">ApprovedVersion</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpMiddle"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">RestoreVersion</span></p>
<p style="margin-bottom: .0001pt; text-indent: -.25in; line-height: normal;" class="MsoListParagraphCxSpLast"><span style="font-size: 10.0pt; font-family: Symbol;">&middot;<span style="font: 7.0pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">PendingVersion</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Pretty cool, huh?</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">As we noted, when you first upload device update rules each rule is marked as Pending; that simply means that the rule version number will be assigned to the PendingVersion property:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">ApprovedVersion :</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">RestoreVersion&nbsp; :</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">PendingVersion&nbsp; : 4.0.7168.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">When you approve a rule, that version number gets assigned to the ApprovedVersion property and the PendingVersion is set to a Null value:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">ApprovedVersion : 4.0.7168.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">RestoreVersion&nbsp; : 4.0.6991.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">PendingVersion&nbsp; : </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So how do you get a list of rules that have been approved? Like this:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Get-CsDeviceUpdateRule | Where-Object {$_.ApprovedVersion &ndash;ne $Null}</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">In other words, if a rule has been approved then the ApprovedVersion property will be equal to <i>something</i>.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And to get a list of rules still in the Pending state? You got it:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Get-CsDeviceUpdateRule | Where-Object {$_.PendingVersion &ndash;ne $Null}</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That just leaves us with the RestoreVersion property and, by extension, the Reset-CsDeviceUpdateRule cmdlet and the Restore-CsDeviceUpdateRule cmdlet. (We're going to take it on faith that you've already figured out that the Remove-CsDeviceUpdateRule cmdlet removes a device update rule.) </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Let's start off by talking about what the Reset-CsDeviceUpdateRule cmdlet does. As we noted earlier, each device update rule begins life by being marked as Pending; as we also noted, that enables administrators to test the update before making it available to users. If the update seems to be working then administrators can mark the update as approved.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Ah, but suppose the update is <i>not</i> working. In that case, administrators can run the Reset-CsDeviceUpdateRule cmdlet against that rule:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsDeviceUpdateRule | Where-Object {$_.Brand -eq "LG-Nortel"} | Reset-CsDeviceUpdateRule</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">What's the point of that? Well, when you do that, the value of the PendingVersion property gets set to null:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">ApprovedVersion: </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">RestoreVersion:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">PendingVersion: </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And what's the point of <i>that</i>? Well, when PendingVersion is set to null, the update in question will be <i>uninstalled</i> from the test devices; in addition, the test devices will re-install their most recently-approved update. With PendingVersion set to null test devices won't bother with the update. And with ApprovedVersion set to null, user devices woin't bother with the update, either. </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Of course, PendingVersion only works with rules that are in the Pending state; that is, rules that have never been approved. Now, suppose you approve a rule and only later discover that the update is causing problems. In that case, Reset-CsDeviceUpdateRule won't do you any good; instead, you'll need to run the Restore-CsDeviceUpdateRule cmdlet instead:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<pre>Get-CsDeviceUpdateRule | Where-Object {$_.Brand -eq "LG-Nortel"} | Restore-CsDeviceUpdateRule</pre>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">So what does <i>that</i> command do? Well, we kind of skipped over this earlier, but when you approve a device update rule <i>three</i> things actually happen: 1) the PendingVersion is set to a null value; 2) the ApprovedVersion is set to the version of the newly-approved update rule; and, 3) the RestoreVersion is set to the version number of the rule that was previously-approved for this device. Remember this output:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">ApprovedVersion : 4.0.7168.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">RestoreVersion&nbsp; : 4.0.6991.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">PendingVersion&nbsp; : </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That output tells us that, prior to approving rule 4.0.7168.0, we had approved rule 4.0.6991.1.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Why do we care about the previously-approved rule? Well, we've just discovered that our new rule (rule 4.0.7168.0) doesn't work. If we run the Restore-CsDeviceUpdateRule cmdlet here's what happens:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">ApprovedVersion : 4.0.6991.0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">RestoreVersion &nbsp;: </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">PendingVersion&nbsp; : </span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">See? What Restore-CsDeviceUpdateRule does is take the <i>old</i> rule and make that old rule (4.0.6991.0) the ApprovedVersion. What difference does that make? Well, that will cause all the affected devices to uninstall update 4.0.7168.0 and reinstall 4.0.6991.0. In other words, we put things back the way they were before we installed the update.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. And if there <i>is</i> no previous version? That's fine. In that case, the "bad" update will simply be uninstalled.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Got all that? Admittedly, it's a little complicated, at least at first glance. But it's actually a pretty good system, and it even makes sense once you think about it a bit.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Really.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">See you tomorrow.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. No trees were harmed in the making of today's haiku. However, a rhododendron <i>did</i> lose a few leaves, and a morning glory got its feelings hurt a little. The authors of the Lync Server PowerShell blog deeply regret both of these incidents.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
    <item>
      <title>Haiku #192</title>
      <link>https://docs.microsoft.com/archive/blogs/csps/haiku-192</link>
      <pubDate>Mon, 19 Sep 2011 11:27:14 GMT</pubDate>
      <dc:creator><![CDATA[CSPShell]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/csps/2011/09/19/haiku-192/</guid>
      <description><![CDATA[Seahawk football? Thanks.
But we'll just play with voice route
Cmdlets instead....]]></description>
      <content:encoded><![CDATA[<p><meta name="Generator" content="Microsoft Word 14 (filtered)" /></p>
<div class="WordSection1">
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Seahawk football? Thanks.</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">But we'll just play with voice route</span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><i><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Cmdlets instead. </span></i></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Well, autumn officially arrived in the Pacific Northwest this past weekend. How do we know that? Well, for one thing, the weekend was cold and damp, which is &ndash; well, never mind; come to think of it, it's pretty much <i>always</i> cold and damp here, regardless of the season. On top of that, the Seattle Mariners lost two more games this weekend, meaning they have no chance to &ndash; well, OK, never mind. Not a good example, either.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Wait, here's one: both of our football teams, the Seattle Seahawks and the University of Washington Huskies, got beat this past weekend.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Sorry, Washington State University, but we don't really claim you as one of our football teams. Nevertheless, a tip of the hat to the Cougars for doing a pretty darn good imitation of a Pacific Northwest football team: WSU got whipped by San Diego State (San Diego State?!?) on Saturday.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Now, in all fairness, we should point out that both the Seahawks and Huskies were obviously victims of budget cuts and the economy. With money as tight as it is, the Seahawks were only able to send their defense to Pittsburgh and were forced to leave their offense at home. (And yet, despite that, the team <i>still</i> managed to cross the midfield stripe &ndash; twice.) The Huskies, beset by the same budget woes, decided to leave their defense at home, and, as a result, dropped a 51-38 decision to Nebraska. To put that in perspective, the 1991 Husky team that won the national championship gave up 101 points. That's 101 points over the entire 12-game season. In three games this year, the Huskies have already given up 110 points.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Autumn is such a delightful season.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Speaking of which, there's one other sign that autumn has arrived: we're almost done with the daily Lync Server PowerShell haiku. In fact, after today we'll have just two more nouns to cover: CsCertificate and CsDeviceUpdateRule. At that point, we'll have written haikus for all the Lync Server PowerShell nouns, something they said could never be done!</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Or maybe it was something they said <i>should</i> never be done. But you get the idea.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">At any rate, we'll have more about the haiku of the day &ndash; and our future plans for the Lync Server PowerShell blog &ndash; later. Today we have something way more important to talk about: the state of football in the Pacific Northwest.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">On the other hand, based on the results of this past weekend, there really isn't much to talk about when it comes to football in the Pacific Northwest. So let's talk about the CsVoiceRoute cmdlets instead: </span><a href="https://technet.microsoft.com/en-us/library/gg425926.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Get-CsVoiceRoute</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg398197.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">New-CsVoiceRoute</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, </span><a href="https://technet.microsoft.com/en-us/library/gg398468.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Remove-CsVoiceRoute</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, and </span><a href="https://technet.microsoft.com/en-us/library/gg412893.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Set-CsVoiceRoute</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Oh, and </span><a href="https://technet.microsoft.com/en-us/library/gg425873.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Test-CsVoiceRoute</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, too.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. Don't worry, we'd <i>never</i> forget Test-CsVoiceRoute.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">As you probably know, voice routes are used to route calls from Enterprise Voice users to phone numbers on the public switched telephone network (PSTN) or a public branch exchange (PBX) system. Without getting too technical (in large part because we <i>can't</i> get too technical when it comes to voice routes), any time an Enterprise Voice user places a call Lync Server converts the dialed number to the E.164 format and then tries to match that E.164 number to a SIP URI. If the E.164 number can't be matched to a SIP URI Lync Server then uses voice routes to determine how the call should be handled. For example, if the dialed number is <span style="white-space: nowrap;" class="baec5a81-e4d6-4674-97f3-e9220f0136c1">1-206-555-1219<a style="position: static !important; margin: 0px; width: 16px; bottom: 0px; display: inline; white-space: nowrap; float: none; height: 16px; vertical-align: middle; overflow: hidden; top: 0px; cursor: hand; right: 0px; left: 0px;" title="Call: 1-206-555-1219" href="https://blogs.technet.com/controlpanel/blogs/posteditor.aspx?SelectedNavItem=NewPost&amp;WeblogID=8362"><img style="position: static !important; margin: 0px; width: 16px; bottom: 0px; display: inline; white-space: nowrap; float: none; height: 16px; vertical-align: middle; overflow: hidden; top: 0px; cursor: hand; right: 0px; left: 0px;" title="Call: 1-206-555-1219" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAKLSURBVHjadJPfS5NhFMe/21xvuhXRyJAZroiSrJnbRdT7vrAf5HBaK5RABmEEwQIvkpZ/QRcWXdSFw5soKaF0F7qZeLO13mGBDpQsf5CoxVKHOt0Pctp2uvEdrzG/V+c553w/54HnPDIiQiGpPMETABoB2AAYd9MRAMMAvGmX+RcAyAoBVJ7gZQDtABworH4AHWmX+bOMZdkjCoXiUzabvcAwzPSsob5p/VTNY9GcdpnxdmYZ9wJThSCtCr1e/4XjuNPd3d1KjUZzaGbI27ysqzGQoggAsLa1A7ehArrDxfDNr0oBlQB+wmKxbJFEL968SxoamsjkHaPU9l9piUo6A0RE1DG2QCWdASrpDAzJM5kMI8XecdjVxfEl+K9dxFgsgUvvR6HyBKHyBAEATyKLeGSsENuNcqk5kUjEGm7fzcYqr0ClVODl99+YXEvl6+c1amjVe+ahiGGYaUEQKnmeh91uL43rqheixjpdmzCL11er0PcjhrTLvMfUJsyKYUSeyWQ6enp6tgCgrKxsfbP8bB8AdE1G89cOReMAgOv+Cag8QXRNRkXAsDwcDr+am5tLCYKA3t7eo2dG+1vVK/MfpRPtA+MIReMYaKj+/xm9MiICx3EmpVL5wefzFavValis1u1vvHMkdfykCQC0kSGUTo+Ajmnx1dSC7IGD+UUCEYGIwLKsyWazrSeTSSIiMpnNf7Ttz5+ec96fr7/VnE0mk+QfHMzV3WjcKH/4rEr05QGFIA6HY4llWRLPRER+v3/HYrFMFQSIkNra2tVQKJSlfcSyLO0LECFWq3XF6XRGA4HAptTsdrsXeZ6fEHtl+31nAOA4rkUulz/I5XL63dQGgHEAN8Ph8AYA/BsAt4ube4GblQIAAAAASUVORK5CYII=" /></a></span> a voice route would figure out that this is a call to a US phone number and send the call to the appropriate PSTN gateway. If the dialed number is 44-113-555-1219 a different voice route would recognize that this is a call to a number in the United Kingdom (country code 44) and, in turn, might route the call to a <i>different</i> PSTN gateway. Admittedly, that's a somewhat simplistic explanation of voice routes and how they work, but it'll do for now.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">As for how you create a voice route in the first place, well, here's one example:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">New-CsVoiceRoute -Identity RedmondVoiceRoute -PstnUsages @{add="Long Distance"} -PstnGatewayList @{add="PstnGateway:redmondpool.litwareinc.com"}</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">This happens to be a very basic voice route: it simply specifies an Identity (RedmondVoiceRoute) as well as one PSTN usage and one gateway. (A single route can support multiple PSTN usages and/or multiple gateways.) You can actually create a voice route that doesn't have a PSTN usage or a PSTN gateway; for example, this is a perfectly valid Lync Server PowerShell command:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">New-CsVoiceRoute -Identity RedmondVoiceRoute</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That command will create a voice route, but it will be a totally useless voice route: without a PSTN usage or a PSTN gateway, the route will not be able to forward calls; in turn, that means that your users won't be able to actually <i>place</i> phone calls. The moral of the story? It doesn't make a whole lot of sense to create a voice route that doesn't have at least one PSTN usage and at least one gateway.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<div style="border: solid windowtext 1.0pt; padding: 1.0pt 4.0pt 1.0pt 4.0pt; background: #FFFFCC;">
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Note</span></b><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. So what exactly <i>is</i> a PSTN usage? For more information, take a peek at </span><a href="https://blogs.technet.com/b/csps/archive/2011/03/30/haiku078.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Haiku #78</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">. And, while you're at it, you might spend a few minutes reading </span><a href="https://blogs.technet.com/b/csps/archive/2011/02/01/haiku037.aspx"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Haiku #37</span></a><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">, which gives you the lowdown on PSTN gateways.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal; background: #FFFFCC; border: none; padding: 0in;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That will give you something to do while you wait for the Seahawks to actually score a point.</span></p>
</div>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Incidentally, the voice route we just created basically matches <i>any</i> E.164 number. In turn, that means that any number that gets dialed will be scooped up by this voice route and forwarded to the gateway redmondpool.litwareinc.com. How do we know that? Well, by default the NumberPattern property for a voice route is set to this:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">[0-9]{10}</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That's an odd-looking value, yes, but it's a regular expression that basically says this: if you see a phone number that consists solely of the digits 0 through 9 <i>and</i> that phone number is at least 10 digits long, well, then we've got a match. Needless to say, that's going to basically be any phone that gets converted to the E.164 format. But what if you only wanted to match calls made to the 206 area code in the US? In that case, you'd need to change the NumberPattern. For example:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">-NumberPattern "^1206[0-9]{7}"</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Without going into any details, that matches any number that starts with the value 1206, and then is followed by 7 digits. For example:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">12065551219</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">The other thing you might need to do here is set the Priority for the voice route. As you might recall, the first voice route we created captures pretty much <i>any</i> E.164 phone number; that means it will capture phone calls made to the 206 area code. How do we make sure that our <i>other</i> voice route captures calls made to the 206 area code? One sure-fire way is to set the Priority of the route to 0:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">-Priority 0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">If you run into a situation where multiple voice routes match a given phone number, Lync Server will use the route that has the lowest Priority value. And 0 <i>is</i> the lowest priority.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">By the way, here's the full command that creates a voice route that matches 206 numbers and has a Priority of 0:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">New-CsVoiceRoute -Identity 206AreaCodeVoiceRoute -PstnUsages @{add="Long Distance"} -PstnGatewayList @{add="PstnGateway:redmondpool.litwareinc.com"} -NumberPattern "^1206[0-9]{7}" &ndash;Priority 0</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">And before you ask, yes, this <i>can</i> get complicated. Which is at least one reason why you should carefully plot out your voice routing strategy before you begin creating new voice routes willy-nilly.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Seeing as how New-CsVoiceRoute is used to create new voice routes, it probably comes as no surprise that Remove-CsVoiceRoute is used to remove existing voice routes; Get-CsVoiceRoute is used to return information about existing voice routes; and Set-CsVoiceRoute is used to modify existing voice routes. What kind of things would you ever need to modify in a voice route? Well, here's an interesting example. By default, any call placed using a given voice route will end up displaying the caller's phone number in any Caller ID system. For example, suppose Ken Myer has the phone number 555-0712 and he places a call to Pilar Ackerman. What number is going to show up on Pilar's Caller ID? This number:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">5550712</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">That's fine, but suppose you'd rather have your company's phone number (5551234) show up on Caller ID systems, regardless of whether Ken Myer or anyone else places the call. Can you do that? Sure you can. All you have to do is set the SuppressCallerId property to True, and then specify the number to be displayed as the value of the AlternateCallerId number. You know, like this:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">New-CsVoiceRoute -Identity 206AreaCodeVoiceRoute &ndash;SuppressCallerId $True &ndash;AlternateCallerId "5551234"</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Just a little something you might find useful.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Another little something you might find useful is the Test-CsVoiceRoute cmdlet, which lets you verify that a given phone number will match the NumberPattern for a given voice route. In order to use the Test-CsVoiceRoute cmdlet you need to do two things. First, you need to use the Get-CsVoiceRoute cmdlet to retrieve an object reference to the voice route being tested. For example:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">$x = Get-CsVoiceRoute "206AreaCodeVoiceRoute"</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Second, you need to then use that object reference plus the number being dialed in your call to Test-CsVoiceRoute:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Test-CsVoiceRoute -TargetNumber "12065551212" -Route $x</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">The preceding test should return True. Why? Because the NumberPattern for the 206AreaCodeVoiceRoute is supposed to match any phone number that starts with 1206 and then is followed by at least 7 digits. This command should return False:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Test-CsVoiceRoute -TargetNumber "14255551212" -Route $x</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Why? You got it: because the target number does not start with 1206. And this command will fail because, although the target number starts with 1206, it's not followed by 7 digits:</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Courier New';">Test-CsVoiceRoute -TargetNumber "1206" -Route $x</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">Could we just sit around and run voice route tests all day? You bet we could. But that's mainly because, here in the Pacific Northwest, we don't have any football games worth watching. Those of you who live in Kansas City (and have watched your beloved Chiefs get outscored 89-10 this season) know exactly what we&rsquo;re talking about.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">See you tomorrow.</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
<p style="margin-bottom: .0001pt; line-height: normal;" class="MsoNormal"><span style="font-size: 10.0pt; font-family: 'Verdana','sans-serif';">&nbsp;</span></p>
</div>]]></content:encoded>
    </item>
  </channel>
</rss>