<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Mike Pfeiffer's Blog</title>
	
	<link>http://www.mikepfeiffer.net</link>
	<description>Exploring Microsoft Unified Communications and PowerShell</description>
	<lastBuildDate>Sun, 08 Jan 2012 17:48:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/MikePfeiffer" /><feedburner:info uri="mikepfeiffer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>MikePfeiffer</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Generating Delivery Reports and Tracking Messages from PowerShell</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/IJzAdvb7Jyc/</link>
		<comments>http://www.mikepfeiffer.net/2012/01/generating-delivery-reports-and-tracking-messages-from-powershell/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 17:48:54 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Management Shell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Delivery]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Read]]></category>
		<category><![CDATA[Reports]]></category>
		<category><![CDATA[Tracking]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8844</guid>
		<description><![CDATA[Delivery Reports were introduced in Exchange 2010 and provide a method for users to verify that the messages they’ve sent have been successfully delivered. Users are able to generate these reports from the Delivery Reports screen in the Exchange Control Panel (ECP), which is also where Outlook 2010 will send them when they track a [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Delivery Reports were <a href="http://blogs.technet.com/b/exchange/archive/2010/01/13/exchange-2010-delivery-reports.aspx" target="_blank">introduced in Exchange 2010</a> and provide a method for users to verify that the messages they’ve sent have been successfully delivered. Users are able to generate these reports from the Delivery Reports screen in the Exchange Control Panel (ECP), which is also where Outlook 2010 will send them when they track a message. Since the ECP is driven by Exchange Management Shell cmdlets, we can create and view these reports using PowerShell. This gives you another tool to verify message delivery—in addition to the existing <a href="http://technet.microsoft.com/en-us/library/bb124926.aspx" target="_blank">message tracking</a> search functionality—but it can also provide the "read status" of a message. Let's start off with a basic example.</p>
<p>To create a delivery report from the shell, you first need to use the <a href="http://technet.microsoft.com/en-us/library/dd351138.aspx" target="_blank">Search-MessageTrackingReport</a> cmdlet. This will give you a list of one or more reports, and you'll need to pass the report id returned by this command to another cmdlet to get more details. Because of that, the bast way to handle this is to save the output in a variable:</p>
<pre>$msg = Search-MessageTrackingReport -Identity allen -Recipients rob@uss.local -BypassDelegateChecking</pre>
<p>If you want to search delivery reports for a mailbox other than your own, you need to use the -BypassDelegateChecking switch parameter as well. The search criteria can be based on the recipients of the message, as shown in the previous example, or on the subject of the message using the -Subject parameter.</p>
<p>After the search has completely successfully, use the <a href="http://technet.microsoft.com/en-us/library/dd351082.aspx" target="_blank">Get-MessageTrackingReport</a> cmdlet to review the results. To do this, we can simply iterate over each report id stored in the variable created in the previous step:</p>
<pre>
$msg | %{ Get-MessageTrackingReport -Identity $_.MessageTrackingReportId -BypassDelegateChecking }
</pre>
<p>For each message returned, the results should look similar to the following:</p>
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2012/01/delivery_report_1_b.png" /></p>
<p>You can see that several details about the message are returned, including the delivery status, which was successful.</p>
<p>When tracking the status of a message sent to an external recipient, the we can only track the message as it leaves the last transport server on its way out of the organization. As long as this is successful, the TransferredCount will be incremented and the RecipientTrackingEvents will indicate that the message was transferred to a foreign organization.</p>
<h3>Determining "Read Status" without Read Receipts</h3>
<p>In addition to tracking the successful delivery of messages within the organization, you can also enable read tracking to determine the read status of a message. To do this, you first need to enable read tracking:</p>
<pre>Set-OrganizationConfig -ReadTrackingEnabled $true</pre>
<p>After this command has been run, read tracking will be enabled on all hub transport servers organization wide. By default, read status tracking for mailboxes is enabled. If read tracking needs to be disabled for specific users, you can disable on a per user basis using the Set-Mailbox cmdlet. For example:</p>
<pre>
Set-Mailbox -Identity steve -MessageTrackingReadStatusEnabled $false
</pre>
<p>At this point, read tracking has been enabled at the organization level, and we can determine the read status of a message by checking the delivery report. To do this, we’ll create another search. This time we’ll specify the subject of the e-mail for the search criteria:</p>
<pre>$msg = Search-MessageTrackingReport -Identity allen -Subject 'Testing 1,2,3' -BypassDelegateChecking</pre>
<p>According to the cmdlet help for the Get-MessageTrackingReport cmdlet, we should be able to determine the read status of a message by setting the -Status parameter to <em>Read</em>. So far, I haven't been able to get that to work (I'm looking into this). However, we can still track the read status for messages using the RecipientPath report template when running the Get-MessageTrackingReport cmdlet:</p>
<pre>$msg | %{ Get-MessageTrackingReport -Identity $_.MessageTrackingReportId -BypassDelegateChecking -RecipientPathFilter rob@uss.local -ReportTemplate RecipientPath }</pre>
<p>When using the RecipientPath report template, you also need to set the -RecipientPathFilter parameter to the recipient address for the message. The above command produces the following output:</p>
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2012/01/delivery_report_2_b.png" /></p>
<p>Notice that the RecipentTrackingEvents property shows that the message was submitted, delivered, and is also set to <strong>Read</strong>.</p>
<p>If you don't have organization read tracking enabled, you can still check the read status of a message from PowerShell with the EWS Managed API. There is a great code sample for this posted <a href="http://social.technet.microsoft.com/Forums/en-US/exchange2010/thread/99a2b26d-a672-4c8b-ba51-60ed40feb60b" target="_blank">here</a> by a user in the Exchange 2010 forums on TechNet.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/IJzAdvb7Jyc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2012/01/generating-delivery-reports-and-tracking-messages-from-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2012/01/generating-delivery-reports-and-tracking-messages-from-powershell/</feedburner:origLink></item>
		<item>
		<title>How to Enable Lync 2010 Client Presence Status: Appear Offline</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/KmOwihQ6qLY/</link>
		<comments>http://www.mikepfeiffer.net/2012/01/how-to-enable-lync-2010-client-presence-status-appear-offline/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 17:48:44 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Lync 2010]]></category>
		<category><![CDATA[Office 365]]></category>
		<category><![CDATA[Appear Offline]]></category>
		<category><![CDATA[Client]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Group Policy]]></category>
		<category><![CDATA[LMS]]></category>
		<category><![CDATA[Lync]]></category>
		<category><![CDATA[Lync Online]]></category>
		<category><![CDATA[Office365]]></category>
		<category><![CDATA[policy]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Registry]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8806</guid>
		<description><![CDATA[One of the more common Lync 2010 client questions is: How do I enable "Appear Offline" status? For on-premises deployments, this can easily be controlled using the Lync Management Shell. There is an EnableAppearOffline setting that is controlled by in-band provisioning, which means configuration data is defined via a server-side policy, and downloaded by clients [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>One of the more common Lync 2010 client questions is: How do I enable "Appear Offline" status? For on-premises deployments, this can easily be controlled using the Lync Management Shell. There is an EnableAppearOffline setting that is controlled by in-band provisioning, which means configuration data is defined via a server-side policy, and downloaded by clients after sign-in. You can enable <em>appear offline</em> status for all of your clients by modifying each of your client policies with a simple Lync Management Shell one-liner:</p>
<pre>Get-CSClientPolicy | Set-CSClientPolicy -EnableAppearOffline $true</pre>
<p>Simple enough. Just restart the Lync client and you're all set.</p>
<h3>What about Lync Online Clients?</h3>
<p>If you're using Lync Online, this is a little more involved. Since there is no remote PowerShell interface for Lync Online, you can't change the client policies. You're only option is to fall back to modifying the registry on your client computers. Here is the reg add command you could use to script this:</p>
<pre>Reg Add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Communicator" /V "EnableAppearOffline" /D 1 /T REG_DWORD /F</pre>
<p>As you can see, this will create the HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Communicator key, and then add a 32bit DWORD value under this key called EnableAppearOffline with a value of 1. You could always add this to a custom ADM template and apply the setting via group policy, if that makes things easier.</p>
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2012/01/appear_offline1_b.png" /></p>
<p>In either case, once the EnableAppearOffline setting has been enabled—after signing out and back into the Lync client—users will have the ability to select this option when setting their status, as shown above.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/KmOwihQ6qLY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2012/01/how-to-enable-lync-2010-client-presence-status-appear-offline/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2012/01/how-to-enable-lync-2010-client-presence-status-appear-offline/</feedburner:origLink></item>
		<item>
		<title>Managing Exchange 2010 and Lync 2010 from a Single PowerShell Session</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/dLGBTZUxnag/</link>
		<comments>http://www.mikepfeiffer.net/2012/01/managing-exchange-2010-and-lync-2010-from-a-single-powershell-session/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 17:48:31 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Management Shell]]></category>
		<category><![CDATA[Lync 2010]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[LMS]]></category>
		<category><![CDATA[Lync]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Remoting]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=6318</guid>
		<description><![CDATA[This is question I've been asked several times lately: How do I get the Exchange and Lync cmdlets loaded into the same shell? Well, with PowerShell v3 coming soon, this might not be an issue in the next wave of products thanks to the new auto loading modules feature. We'll see what happens. For now, [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This is question I've been asked several times lately: How do I get the Exchange and Lync cmdlets loaded into the same shell? Well, with PowerShell v3 coming soon, this might not be an issue in the next wave of products thanks to the new auto loading modules feature. We'll see what happens. For now, there are a couple of options, but in both cases you'll probably want to setup a profile so it happens automatically when you start the shell. In this post I'll show you how to go about loading the cmdlets from a profile when the management tools are installed, and also how to use PowerShell remoting to load the cmdlets on workstations or servers that do not have the tools installed locally.</p>
<h3>Management tools installed locally</h3>
<p>If you have both the Exchange 2010 Management tools, as well as the Lync Server 2010 Management Tools installed on your workstation, add the following code to your PowerShell profile. If you don't have a profile setup, run <a href="http://technet.microsoft.com/en-us/library/dd315342.aspx">Get-Help about_Profiles</a> to learn how to create one. It's basically like a logon script for your PowerShell session. Here's the code you'd add to the profile:</p>
<pre class=PowerGuiCommand><span style="color: #008000;">#</span><span style="color: #008000;">Load the Exchange cmdlets</span><span style="color: #008000;">
</span><span style="color: #000000;">. </span><span style="color: #800000;">'</span><span style="color: #800000;">C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1</span><span style="color: #800000;">'</span><span style="color: #000000;">
Connect-ExchangeServer -auto

</span><span style="color: #008000;">#</span><span style="color: #008000;">Import the Lync module</span><span style="color: #008000;">
</span><span style="color: #5F9EA0; font-weight: bold;">Import-Module</span><span style="color: #000000;"> </span><span style="color: #800000;">Lync</span></pre>
<p>As you can see here, were importing (also known as dotting or dot-sourcing) the RemoteExchange.ps1 script that is installed along with the Exchange tools. This will import the Exchange 2010 cmdlets and load some Exchange specific functions into the shell—one of which is the Connect-ExchangeServer function that will automatically connect to an Exchange server in the local AD site. After that, the Lync module is imported with a simple one-liner.</p>
<h3>Remoting (management tools not installed)</h3>
<p>If you don't have the Exchange 2010 Manangement tools, or the Lync 2010 Management Tools installed on your workstation, you can still manage both products from the command line using PowerShell remoting. Use the following syntax when setting up your PowerShell profile, but remember to update the server names to match your own environment:</p>
<pre class=PowerGuiCommand><span style="color: #008000;">#</span><span style="color: #008000;">Load the Exchange cmdlets</span><span style="color: #008000;">
</span><span style="color: #800080;">$exch</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-PSSession</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ConfigurationName</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Exchange</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ConnectionUri</span><span style="color: #000000;"> http://exchange1/powershell
</span><span style="color: #5F9EA0; font-weight: bold;">Import-PSSession</span><span style="color: #000000;"> </span><span style="color: #800080;">$exch</span><span style="color: #000000;">

</span><span style="color: #008000;">#</span><span style="color: #008000;">Import the Lync module</span><span style="color: #008000;">
</span><span style="color: #800080;">$lyncOptions</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-PSSessionOption</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-SkipRevocationCheck</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-SkipCACheck</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-SkipCNCheck</span><span style="color: #000000;">
</span><span style="color: #800080;">$lync</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-PSSession</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ConnectionUri</span><span style="color: #000000;"> https://lync1/ocspowershell </span><span style="color: #5F9EA0; font-weight: bold;">`</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-style: italic;">-SessionOption</span><span style="color: #000000;"> </span><span style="color: #800080;">$lyncOptions</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">`</span><span style="color: #000000;">
</span><span style="color: #5F9EA0; font-style: italic;">-Authentication</span><span style="color: #000000;"> </span><span style="color: #800000;">NegotiateWithImplicitCredential</span><span style="color: #000000;">

</span><span style="color: #5F9EA0; font-weight: bold;">Import-PSSession</span><span style="color: #000000;"> </span><span style="color: #800080;">$lync</span></pre>
<p>This code will import both the Exchange 2010 and Lync Server 2010 cmdlets into your shell session using implicit remoting. This code assumes you're using a domain account that has been assigned permissions in both Exchange and Lync, and your logged on Windows credentials will be used for authentication.</p>
<p>Also, notice that when importing the cmdlets from a Lync server, you need to specify an https end-point for the connection uri. This is because the OCSPowerShell virtual directory in IIS requires SSL. By default, this is secured with a self-signed certificate, so we've used a custom session options object to ignore SSL certificate validation.</p>
<h3>Making use of the Pipeline</h3>
<p> Now that you've got the cmdlets for both products loaded into a single session, you can work more efficiently. For example, you can kill two birds with one stone when it comes to mailbox-enabling and lync-enabling a user:</p>
<pre>Enable-Mailbox -Identity Bob |
  Select-Object -Expand Identity |
    Enable-CsUser -SipAddressType EmailAddress -RegistrarPool pool.uclabs.ms
</pre>
<p>The Enable-Mailbox cmdlet creates a mailbox for an existing Active Directory user, but also outputs the Identity of the user upon completion. This object can be sent down the pipeline to Enable-CsUser, which happens to accept input via the pipeline for the Identity parameter. So with a quick one-liner, you can setup a user with a mailbox and lync-enabled account. Piping New-Mailbox to Enable-Csuser would also work using the above syntax.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/dLGBTZUxnag" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2012/01/managing-exchange-2010-and-lync-2010-from-a-single-powershell-session/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2012/01/managing-exchange-2010-and-lync-2010-from-a-single-powershell-session/</feedburner:origLink></item>
		<item>
		<title>How to Generate an Exchange 2010 Room List Report with PowerShell</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/tmyRArV8yTA/</link>
		<comments>http://www.mikepfeiffer.net/2011/12/how-to-generate-an-exchange-2010-room-list-report-with-powershell/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 04:43:39 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Management Shell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Room Finder]]></category>
		<category><![CDATA[RoomList]]></category>
		<category><![CDATA[Rooms]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8571</guid>
		<description><![CDATA[If you work in an campus type of environment, where you have conference rooms spread out across multiple buildings or physical sites, you may have heard of the Room Finder functionality introduced with Exchange 2010 and Outlook 2010. The Room Finder allows users to easily locate a room resource when scheduling a meeting in Outlook. [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>If you work in an campus type of environment, where you have conference rooms spread out across multiple buildings or physical sites, you may have heard of the Room Finder functionality introduced with Exchange 2010 and Outlook 2010. The Room Finder allows users to easily locate a room resource when scheduling a meeting in Outlook. Instead of users having to scroll through the Global Address List (GAL) or try to guess which room resources are located in a particular location, they can select the appropriate room list, and see all of the available rooms. Take a look at this screen shot to see this in action:</p>
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/12/room__1.png" /></p>
<p>Room lists are essentially just a special type of Distribution Group in Exchange. To populate the room list, you simply add one or more resource mailboxes to the group. After you've defined several room lists, you'll probably get to the point where you need to generate a report listing all of the room lists and their associated resource mailboxes. The key to generating a report is to simply query the members of each distribution group that are designated as a room list. Take a look at the following code:</p>
<pre class=PowerGuiCommand><span style="color: #0000FF;">foreach</span><span style="color: #000000;">(</span><span style="color: #800080;">$roomlist</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> Get-DistributionGroup -RecipientTypeDetails RoomList) {
  </span><span style="color: #800080;">$roomlistname</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$roomlist</span><span style="color: #000000;">.DisplayName
  Get-DistributionGroupMember </span><span style="color: #800080;">$roomlist</span><span style="color: #000000;">.alias |
    </span><span style="color: #5F9EA0; font-weight: bold;">Select-Object</span><span style="color: #000000;"> @{n</span><span style="color: #FF0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Room List</span><span style="color: #800000;">"</span><span style="color: #000000;">;e</span><span style="color: #FF0000;">=</span><span style="color: #000000;">{</span><span style="color: #800080;">$roomlistname</span><span style="color: #000000;">}},
                  @{n</span><span style="color: #FF0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Room</span><span style="color: #800000;">"</span><span style="color: #000000;">;e</span><span style="color: #FF0000;">=</span><span style="color: #000000;">{</span><span style="color: #800080;">$_</span><span style="color: #000000;">.DisplayName}}
}</span></pre>
<p>In a perfect world this code would be more elegant and make better use of the pipeline, but the foreach loop is used here as a <a href="http://www.mikepfeiffer.net/2010/02/exchange-management-shell-error-pipelines-cannot-be-executed-concurrently/" target="_blank">workaround</a>. Notice that as we iterate over each group, where retrieving the list of members using the Get-DistributionGroupMember cmdlet. When then pipe the output to Select-Object, where we use calculated properties to build a custom object:</p>
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/12/room_2.png" /></p>
<p>This is good for reviewing the room lists members interactively, but in most cases you'll need to output this to an external file. We can do this by making a simple adjustment to our previous example. Simply save the output to a variable, and use that as your InputObject with Export-CSV, Out-File, etc.</p>
<pre class=PowerGuiCommand><span style="color: #800080;">$rooms</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">foreach</span><span style="color: #000000;">(</span><span style="color: #800080;">$roomlist</span><span style="color: #000000;"> </span><span style="color: #0000FF;">in</span><span style="color: #000000;"> Get-DistributionGroup -RecipientTypeDetails RoomList) {
  </span><span style="color: #800080;">$roomlistname</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$roomlist</span><span style="color: #000000;">.DisplayName
  Get-DistributionGroupMember </span><span style="color: #800080;">$roomlist</span><span style="color: #000000;">.alias |
    </span><span style="color: #5F9EA0; font-weight: bold;">Select-Object</span><span style="color: #000000;"> @{n</span><span style="color: #FF0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Room List</span><span style="color: #800000;">"</span><span style="color: #000000;">;e</span><span style="color: #FF0000;">=</span><span style="color: #000000;">{</span><span style="color: #800080;">$roomlistname</span><span style="color: #000000;">}},
                  @{n</span><span style="color: #FF0000;">=</span><span style="color: #800000;">"</span><span style="color: #800000;">Room</span><span style="color: #800000;">"</span><span style="color: #000000;">;e</span><span style="color: #FF0000;">=</span><span style="color: #000000;">{</span><span style="color: #800080;">$_</span><span style="color: #000000;">.DisplayName}}
}

</span><span style="color: #5F9EA0; font-weight: bold;">Export-Csv</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-InputObject</span><span style="color: #000000;"> </span><span style="color: #800080;">$rooms</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Path</span><span style="color: #000000;"> </span><span style="color: #800000;">C:\rooms.csv</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-NoTypeInformation</span></pre>
<p>After running the above code, you could open up the rooms.csv file in Excel and use the <a href="http://www.microsoft.com/canada/smallbiz/products/howto/use-excel-filtering-to-find-data-fast.mspx" target="_blank">Filter</a> feature to easily view the rooms associated with each list. For more details on the Room Finder, check out <a href="http://blogs.technet.com/b/exchange/archive/2010/04/14/3409791.aspx" target="_blank">this</a> post on the Exchange Team blog.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/tmyRArV8yTA" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/12/how-to-generate-an-exchange-2010-room-list-report-with-powershell/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/12/how-to-generate-an-exchange-2010-room-list-report-with-powershell/</feedburner:origLink></item>
		<item>
		<title>How to use a Proxy Server with the EWS Managed API and PowerShell</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/eYLnFJh8wrM/</link>
		<comments>http://www.mikepfeiffer.net/2011/12/how-to-use-a-proxy-server-with-the-ews-managed-api-and-powershell/#comments</comments>
		<pubDate>Sun, 11 Dec 2011 23:38:55 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Online]]></category>
		<category><![CDATA[Exchange Web Services]]></category>
		<category><![CDATA[Office 365]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Office365]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8598</guid>
		<description><![CDATA[You might work in an environment where all web traffic must go through an outbound web proxy. Of course, this can add some complexity when it comes to writing EWS scripts that target an external Exchange organization, such as a partner or a hosted platform like Exchange Online available through Office 365. Luckily, EWS supports [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>You might work in an environment where all web traffic must go through an outbound web proxy. Of course, this can add some complexity when it comes to writing EWS scripts that target an external Exchange organization, such as a partner or a hosted platform like Exchange Online available through Office 365. Luckily, EWS supports the use of a web proxy, and this can be set via the ExchangeService object. Let's take a look at a couple of examples.</p>
<p>First, create an instance of the System.Net.WebProxy class, and set the URI for the proxy:</p>
<pre>
$proxy = new-object System.Net.WebProxy('http://tmg:8080')
</pre>
<p>Next, you can set the required user name and password on the $proxy object using the Credentials property, or you can use your logged on Windows credentials by setting the UseDefaultCredentials property to $true:</p>
<pre>
$proxy.UseDefaultCredentials = $true
</pre>
<p>Finally, assign your proxy object to the WebProxy property of your ExchangeService object:</p>
<pre>
$service.WebProxy = $proxy
</pre>
<p>Here's some code that uses the EWS Managed API 1.1 to send an e-mail message from an Exchange Online mailbox, with all of the web service operations going through an outbound proxy server:</p>
<pre class=PowerGuiScript><span style="color: #5F9EA0; font-weight: bold;">Add-Type</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-Path</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll</span><span style="color: #800000;">'</span><span style="color: #000000;">
</span><span style="color: #800080;">$service</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Exchange.WebServices.Data.ExchangeService</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ArgumentList</span><span style="color: #000000;"> </span><span style="color: #800000;">Exchange2010_SP1</span><span style="color: #000000;">
</span><span style="color: #800080;">$service</span><span style="color: #000000;">.Credentials </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Exchange.WebServices.Data.WebCredentials</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ArgumentList</span><span style="color: #000000;">  </span><span style="color: #800000;">'</span><span style="color: #800000;">user@yourdomain.onmicrosoft.com</span><span style="color: #800000;">'</span><span style="color: #000000;">, </span><span style="color: #800000;">'</span><span style="color: #800000;">P@ssw0rd</span><span style="color: #800000;">'</span><span style="color: #000000;">

</span><span style="color: #800080;">$proxy</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">new-object</span><span style="color: #000000;"> </span><span style="color: #800000;">System.Net.WebProxy</span><span style="color: #000000;">(</span><span style="color: #800000;">'</span><span style="color: #800000;">http://tmg:8080</span><span style="color: #800000;">'</span><span style="color: #000000;">)
</span><span style="color: #800080;">$proxy</span><span style="color: #000000;">.UseDefaultCredentials </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$true</span><span style="color: #000000;">
</span><span style="color: #800080;">$service</span><span style="color: #000000;">.WebProxy </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$proxy</span><span style="color: #000000;">

</span><span style="color: #800080;">$service</span><span style="color: #000000;">.AutodiscoverUrl(</span><span style="color: #800000;">'</span><span style="color: #800000;">user@yourdomain.onmicrosoft.com</span><span style="color: #800000;">'</span><span style="color: #000000;">, {</span><span style="color: #800080;">$true</span><span style="color: #000000;">})

</span><span style="color: #800080;">$message</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-weight: bold;">New-Object</span><span style="color: #000000;"> </span><span style="color: #800000;">Microsoft.Exchange.WebServices.Data.EmailMessage</span><span style="color: #000000;"> </span><span style="color: #5F9EA0; font-style: italic;">-ArgumentList</span><span style="color: #000000;"> </span><span style="color: #800080;">$service</span><span style="color: #000000;">
</span><span style="color: #800080;">$message</span><span style="color: #000000;">.Subject </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">Test is a test</span><span style="color: #800000;">'</span><span style="color: #000000;">
</span><span style="color: #800080;">$message</span><span style="color: #000000;">.Body </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">This message is being sent through EWS with PowerShell</span><span style="color: #800000;">'</span><span style="color: #000000;">
</span><span style="color: #800080;">$message</span><span style="color: #000000;">.ToRecipients.Add(</span><span style="color: #800000;">'</span><span style="color: #800000;">sysadmin@contoso.com</span><span style="color: #800000;">'</span><span style="color: #000000;">)
</span><span style="color: #800080;">$message</span><span style="color: #000000;">.SendAndSaveCopy()</span></pre>
<p>This post was a response to a query from one of my readers — thanks for the question, Nick. As a side note, the above code sample is based on a snippet from my guest post on the Hey Scripting Guy blog from a while back. For more details, you can <a href="http://blogs.technet.com/b/heyscriptingguy/archive/2011/09/24/send-email-from-exchange-online-by-using-powershell.aspx" target="_blank">check it out here</a>.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/eYLnFJh8wrM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/12/how-to-use-a-proxy-server-with-the-ews-managed-api-and-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/12/how-to-use-a-proxy-server-with-the-ews-managed-api-and-powershell/</feedburner:origLink></item>
		<item>
		<title>How to Add Exchange Proxy Addresses from a CSV File with PowerShell</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/hDPzqqMM09s/</link>
		<comments>http://www.mikepfeiffer.net/2011/12/how-to-add-exchange-proxy-addresses-from-a-csv-file-with-powershell/#comments</comments>
		<pubDate>Sat, 03 Dec 2011 19:38:27 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Management Shell]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Address]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[ProxyAddress]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8526</guid>
		<description><![CDATA[I recently had the opportunity to give a presentation on the Idera PowerShell Power Hour Webcast. The topic was Exchange Enterprise Management with PowerShell, and I was excited to be able to answer so many great questions during the Q and A portion of the webcast. One request for help required a more lengthy explanation [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>I recently had the opportunity to give a presentation on the <a href="http://www.idera.com/Education/PowerShell-Webcasts/?s=PScom" target="_blank">Idera PowerShell Power Hour Webcast</a>. The topic was Exchange Enterprise Management with PowerShell, and I was excited to be able to answer so many great questions during the Q and A portion of the webcast. One request for help required a more lengthy explanation that I couldn't provide via web chat, and that's the reason for this post. If you've ever wanted to add one or more proxy address to a list of mailboxes from a CSV file, the solution provided here is for you.</p>
<p>First let me say that adding proxy addresses to multiple recipients can be done even easier with E-Mail Address Policies. You can read all about them <a href="http://technet.microsoft.com/en-us/library/bb232171.aspx" target="_blank">here</a>. However, if you are determined to get this done using PowerShell, it's actually pretty simple to do. I am going to assume you are at least running Exchange 2010 SP1, and that will allow us to utilize <a href="http://blogs.technet.com/b/dstrome/archive/2011/05/29/multivalued-properties-in-exchange-2010.aspx" target="_blank">this</a> cool hash table trick that can be used to add and remove values from multivalued properties.</p>
<p>Let's say that you have a CSV file setup like the following:</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/12/csv2.png" /></p>
<p>The <strong>Name</strong> column shown above contains aliases for existing mailbox-enabled users. The <strong>ProxyAddresses</strong> column contains a semi-colon separated list of addresses that need to be added to each associated mailbox. The key to making this work is converting the ProxyAddresses value into a collection of addresses. We can use the Import-CSV cmdlet to read our source file, and for each record, we'll process the list of ProxyAddresses by adding them to each corresponding mailbox. Let's start first with a simple example:</p>
<pre>
PS C:\> Import-Csv C:\AddressList.csv | ForEach-Object{$_.ProxyAddresses -split ';'}
ds@domain1.com
dave@domain2.com
sd@domain1.com
steve@domain2.com
</pre>
<p>Notice that as we loop through each record, we take the value assigned to the ProxyAddresses column and split it into an array using the PowerShell v2 split operator. When we split this value, we can simply iterate over each item returned and the add proxy addresses to the mailbox. Here's our final code sample that will get this job done:</p>
<pre class=PowerGuiCommand><span style="color: #5F9EA0; font-weight: bold;">Import-Csv</span><span style="color: #000000;"> </span><span style="color: #800000;">C:\AddressList.csv</span><span style="color: #000000;"> | </span><span style="color: #5F9EA0; font-weight: bold;">ForEach-Object</span><span style="color: #000000;">{
  </span><span style="color: #800080;">$name</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$_</span><span style="color: #000000;">.Name
  </span><span style="color: #800080;">$proxy</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$_</span><span style="color: #000000;">.ProxyAddresses </span><span style="color: #FF0000;">-split</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #800000;">;</span><span style="color: #800000;">'</span><span style="color: #000000;">
  Set-Mailbox -Identity </span><span style="color: #800080;">$name</span><span style="color: #000000;"> -EmailAddresses @{add</span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$proxy</span><span style="color: #000000;">}
}</span></pre>
<p>The -EmailAddresses parameter is available for cmdlets that modify other recipient types. If needed, replace the call to Set-Mailbox with Set-MailUser, Set-MailContact, etc. and use the same kind of syntax to add proxy addresses.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/hDPzqqMM09s" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/12/how-to-add-exchange-proxy-addresses-from-a-csv-file-with-powershell/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/12/how-to-add-exchange-proxy-addresses-from-a-csv-file-with-powershell/</feedburner:origLink></item>
		<item>
		<title>How to Manage Your Exchange 2010 Organization with PowerShell Implicit Remoting over the Internet</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/HQ75YdT59kE/</link>
		<comments>http://www.mikepfeiffer.net/2011/09/how-to-manage-your-exchange-2010-organization-with-powershell-implicit-remoting-over-the-internet/#comments</comments>
		<pubDate>Sun, 18 Sep 2011 00:46:45 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[EMS]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Remoting]]></category>
		<category><![CDATA[TMG]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8338</guid>
		<description><![CDATA[This post is inspired by a question asked during my presentation at the last Arizona PowerShell User Group (AZPOSH) meeting. After I demonstrated Exchange management via PowerShell implicit remoting, one of our members said, "Ok, so how do I do that over the internet?". Due to time constraints, I didn't go into it the process [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This post is inspired by a question asked during my presentation at the last Arizona PowerShell User Group (<a href="http://www.azposh.com/" target="_blank">AZPOSH</a>) meeting. After I demonstrated Exchange management via PowerShell <a href="http://www.mikepfeiffer.net/2010/02/managing-exchange-2010-with-remote-powershell/" target="_blank">implicit remoting</a>, one of our members said, "Ok, so how do I do that over the internet?". Due to time constraints, I didn't go into it the process in great detail, so I've decided to do that here, in this post. To demonstrate this configuration, I'll use a basic topology with a single Exchange 2010 server running the core roles (hub, cas, mailbox). I will be publishing the PowerShell virtual directory to the internet via HTTPS using Forefront Threat Management Gateway (TMG), as shown in the diagram below.</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/lab_topology.png" style="padding-left:20px;" /></p>
<p>Implementing a TMG server is not a requirement to make this work. But, when it comes to exposing Exchange servers to the Internet, its considered a best practice to publish them using a reverse proxy solution, such as TMG or UAG. However, you could accomplish this using a simple NAT translation on your firewall, directing traffic from the internet directly to your Exchange server on the internal network. If someone wanted to roll the dice and go with that type of configuration, they could skip the upcoming section on TMG, but it increases the attack surface and is considered bad practice.</p>
<h3>Configuration Steps on the Exchange Server</h3>
<p>The only thing that needs to be done on the Exchange server is a modification to the PowerShell virtual directory in IIS. In the Exchange Management Shell, use the following one-liner to enable Basic Authentication for the PowerShell virtual directory:</p>
<pre>
Get-PowerShellVirtualDirectory | Set-PowerShellVirtualDirectory -BasicAuthentication $true
</pre>
<p>Specifying the identity of the virtual directory is easier done via the pipeline, as shown above. However, this command would modify the virtual directory on every Exchange server in the organization, if you had more than one. If you want to specify a particular server, use the -Server parameter with the <em>Get</em> cmdlet, and pipe that over to the <em>Set</em> cmdlet. </p>
<h3>TMG Configuration</h3>
<p>I don't want to reinvent the wheel here, so I'm just gonna focus the bare minimum. I'm assuming that if you have TMG and Exchange, you probably already have at least OWA published . If you need step-by-step guidance on installing certificates, and publishing Exchange services, such as OWA and Outlook Anywhere, then you should read Greg Taylor's whitepaper titled <a href="http://go.microsoft.com/fwlink/?LinkId=197136" target="_blank">Publishing Exchange Server 2010 with Forefront UAG and TMG</a>.</p>
<p>The upcoming TMG configuration steps are based on the following assumptions.</p>
<ul>
<li><strong>Certificates</strong> — You already have a 3rd party commercial certificate installed on the TMG server, it includes SANs for OWA, Outlook Anywhere, and maybe even Autodiscover. For example, mail.interfacettlabs.com, oa.interfacettlabs.com, autodiscover.interfacettlabs.com, etc.</li>
<li><strong>Listener</strong> — The TMG server is running in workgroup mode, you're using secure LDAP to pre-authenticate users against Active Directory, and your commercial certificate is associated with the listener.</li>
<li><strong>Publishing Rule</strong> — You have publishing rules for OWA, Outlook Anywhere, and maybe even for ActiveSync. We won't touch these, we'll create a new publishing rule for PowerShell.</li>
</ul>
<p>There are several ways to deploy TMG, so in reality, your deployment does not need to match the above configuration. For example, you're not required to use pre-authentication, although it's practically pointless not to. Again, check out the whitepaper for more details if you need to deploy TMG from scratch. With all of that in mind, let's get started. </p>
<ol>
<li>From within the TMG console, right click on <strong>Firewall Policy</strong>, go to <strong>New</strong>, and select <strong>Web Site Publishing Rule</strong>:
<p><img class="aligncenter size-full wp-image-3478;" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg1.png" /></li>
<li>On the New Web Publishing Rule Wizard, enter a name for your rule, such as <strong>Exchange PowerShell</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg2.png" /></li>
<li>For the Rule Action, select <strong>Allow</strong>, otherwise we won't be able to connect. Click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg3.png" /></li>
<li>In our lab topology, we only had one server, so we'll select <strong>Publish a Single Website or Load Balancer</strong> and click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg4.png" /></li>
<li>Stick with the default Server Connection Security setting and use SSL to connect to the published web site, which in this case is hosted on the Exchange 2010 server. This will ensure that remote PowerShell connections use bridged SSL; meaning encrypted from the internet to TMG, and then from TMG to Exchange. Click on <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg5.png" /></li>
<li>On the Internal Publishing Details screen, enter the FQDN the TMG server should use to connect to the Exchange server and click on <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg6.png" /></li>
<li>Next, you'll need to enter <strong>/powershell/*</strong> for the path to be published on the Exchange server. Click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg7.png" /></li>
<li>Now you'll need to enter your externally accessible FQDN in the public name field. Again, the path should be <strong>/powershell/*</strong> and click on <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg8.png" /></li>
<li>As discussed previously, we'll use a listener that was configured for one of the other Exchange publishing rules. Click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg9.png" /></li>
<li>This next step is important. On the Authentication Delegation screen, select <strong>Basic Authentication</strong>. This needs to match the authentication settings for the virtual directory, which was already configured in the previous section. Click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg10.png" /></li>
<li>On the User Sets screen, keep the default setting of <strong>All Authenticated Users</strong>. Click <strong>Next</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg11.png" /></li>
<li>Finally, the PowerShell IIS application on the Exchange server has been published. Click on <strong>Finish</strong>:
<p><img class="aligncenter size-full wp-image-3478" style="margin-top:20px;" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg12.png" /></li>
</ol>
<h3>Testing it out</h3>
<p>Go to any machine external to your environment that has an internet connection. This can be any machine with PowerShell v2, it doesn't need to be in the same domain as the Exchange server. Start PowerShell and use the following syntax to create a new session:</p>
<pre style="height:35px;">
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://mail.interfacettlabs.com/powershell -Authentication basic -Credential (Get-Credential)
</pre>
<p><img class="aligncenter size-full wp-image-3478" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg_powershell_1.png" /></p>
<p>This command will prompt you for your domain credentials, then establish a PSSession with the Exchange server published through TMG. Notice that we've specified Basic authentication, and used the public name as the FQDN in the connection uri. After the session is created, the next step is to import it:</p>
<pre>
Import-PSSession $session
</pre>
<p><img class="aligncenter size-full wp-image-3478" src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/tmg_powershell_2.png" /></p>
<p>As you can see, it works perfectly. You should now have a publicly accessible endpoint for managing your on-premise Exchange environment through PowerShell remoting. As it turns out, the implicit remoting configuration is identical for Office 365, see <a href="http://www.mikepfeiffer.net/2010/11/office-365-connecting-to-exchange-online-with-remote-powershell/" target="_blank">this post</a> for more details on that.</p>
<h3>One Last Note on Testing in Lab Environments</h3>
<p>If you are doing this in a lab, you might be dealing with self-signed certificates, or certificates issued from an internal CA. Depending on the client you are testing from, the certificates may not be trusted, and PowerShell may not be able to validate the certificates, depending on a number of factors. To get around this and basically ignore all certificate issues all together, you can create a PSSessionOption object that disables these certificate validation checks:</p>
<pre>
$so = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
</pre>
<p>Then make sure you assign that PSSessionOption object to the -SessionOption parameter of New-PSSession:</p>
<pre style="height:35px;">
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://mail.interfacettlabs.com/powershell -Authentication basic -Credential (Get-Credential) -SessionOption $so
</pre>
<p>And finally, import the session:</p>
<pre>
Import-PSSession $session
</pre>
<p>That concludes this post, I hope you find it useful, or at least interesting. For more on managing Exchange via remoting, check out my previous posts on the subject, all of which can be found <a href="http://www.mikepfeiffer.net/tag/remoting/" target="_blank">here</a>.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/HQ75YdT59kE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/09/how-to-manage-your-exchange-2010-organization-with-powershell-implicit-remoting-over-the-internet/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/09/how-to-manage-your-exchange-2010-organization-with-powershell-implicit-remoting-over-the-internet/</feedburner:origLink></item>
		<item>
		<title>Windows Server 8 Developer Preview and PowerShell v3 First Look</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/MDp_BREEIq4/</link>
		<comments>http://www.mikepfeiffer.net/2011/09/windows-server-8-developer-preview-and-powershell-v3-first-look/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 04:31:13 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[v3]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8223</guid>
		<description><![CDATA[Tuesday night I downloaded and installed the Windows 8 Developer Preview and got a chance to test drive PowerShell v3. Pretty impressive so far — you should go download it and check it out. Tonight I decided to download the new Windows Server 8 preview to compare the differences between the client and server operating [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Tuesday night I downloaded and installed the <a href="http://www.mikepfeiffer.net/2011/09/windows-8-developer-preview-and-powershell-v3-first-look/">Windows 8 Developer Preview</a> and got a chance to test drive PowerShell v3. Pretty impressive so far — you should go download it and check it out. Tonight I decided to download the new Windows Server 8 preview to compare the differences between the client and server operating systems. One of the things that confused me about 2008 R2 was that there were PowerShell modules for things like Windows Failover Clustering and Network Load Balancing, and not for major core services. For example, there were no cmdlets for basic server administration tasks like managing DNS, DHCP, or File and Print services. Well, the good news is that will change with Windows Server 8.</p>
<h3>DNS</h3>
<p>Want to add a host (A) record to a DNS zone on a 2008 R2 box using the shell? Sounds seemingly simple, yet it is actually not an easy thing to do. In the Windows Server 8 preview there is a DnsServer module, and as you would expect, you can accomplish this with just a couple of commands. Once the DNS server role is installed, import the module:</p>
<pre>
Import-Module DnsServer
</pre>
<p>Then its just a matter of running the Add-DnsServerResourceRecordA cmdlet:</p>
<pre>
Add-DnsServerResourceRecordA -Name mail2 -IPv4Address 192.168.0.10 -ZoneName powershell.local
</pre>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/server8_powershell_v3_3.png" /></p>
<p>Of course, there are plenty of other cmdlets in this module that allow you to add, modify, and remove other types of DNS records, as well as modify zone settings, and more.</p>
<h3>DHCP</h3>
<p>There are over a hundred cmdlets in the DhcpServer module. From reviewing the output of<em>Get-Command -Module DhcpServer</em>, it looks like just about anything that can be done with Dhcp can be scripted through PowerShell v3. One of the most obvious examples would be creating a scope. Just import the module after the role is installed:</p>
<pre>
Import-Module DhcpServer
</pre>
<p>And run the Add-DhcpServerv4Scope cmdlet:</p>
<div class=code style="width:auto;height:35px;">
Add-DhcpServerv4Scope -Name LAN -StartRange 192.168.0.20 -EndRange 192.168.0.50 -SubnetMask 255.255.255.0 -LeaseDuration (New-TimeSpan -Days 4)</p>
</div>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/server8_powershell_v3_5.png" /></p>
<p>Here's the output from Get-DhcpServerv4Scope after I created my scope:</p>
<pre>
PS C:\> Get-DhcpServerv4Scope | fl

ScopeId          : 192.168.0.0
Name             : LAN
Description      :
SuperscopeName   :
SubnetMask       : 255.255.255.0
StartRange       : 192.168.0.20
EndRange         : 192.168.0.50
LeaseDuration(s) : 4.00:00:00
NapProfile       :
NapEnable        : False
Delay(ms)        : 0
State            : Active
Type             : Dhcp
MaxBootpClients  : 4294967295
ActivatePolicies : True
</pre>
<p>This is not only going to be great for automation, but also for reporting.</p>
<h3>File and Print Services</h3>
<p>For managing file and print services there are a couple of different modules. First, the FileServer module contains over 40 cmdlets that allow you to add, remove, and modify shares. You can also do other things, like killing all open files with a one-liner:</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/server8_powershell_v3_6.png" /></p>
<p>In addition, there is a module called PrintManagement. As usual, the cmdlet names are pretty self describing:</p>
<pre>
PS C:\> Get-Command -Module PrintManagement

CommandType     Name                    ModuleName
-----------     ----                    ----------
Function        Add-Printer             PrintManagement
Function        Add-PrinterDriver       PrintManagement
Function        Add-PrinterPort         PrintManagement
Function        Get-PrintConfig         PrintManagement
Function        Get-Printer             PrintManagement
Function        Get-PrinterDriver       PrintManagement
Function        Get-PrinterPort         PrintManagement
Function        Get-PrintJob            PrintManagement
Function        Remove-Printer          PrintManagement
Function        Remove-PrinterDriver    PrintManagement
Function        Remove-PrinterPort      PrintManagement
Function        Remove-PrintJob         PrintManagement
Function        Rename-Printer          PrintManagement
Function        Restart-PrintJob        PrintManagement
Function        Resume-PrintJob         PrintManagement
Function        Set-PrintConfig         PrintManagement
Function        Set-Printer             PrintManagement
Function        Suspend-PrintJob        PrintManagement
</pre>
<p>I could go on and on, but I think you get the idea. I'll be posting a lot more about PowerShell v3 and Server 8 in the future. If you have an MSDN subscription, head over to the <a href="http://msdn.microsoft.com/en-us/subscriptions/default.aspx" target="_blank">MSDN Subscriber</a> site now and download the bits.</p>
<p><strong>Edit - 9/16/2011 3:20:05 PM</strong>: I was chatting with PowerShell MVP <a href="http://twitter.com/#!/alexandair">alexandair</a> earlier today and realized that these modules don't need to be explicitly loaded. For example, if you run the Get-DhcpServerv4Scope cmdlet, PowerShell will automatically load the DhcpServer module for you.....awesome stuff!!!</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/MDp_BREEIq4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/09/windows-server-8-developer-preview-and-powershell-v3-first-look/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/09/windows-server-8-developer-preview-and-powershell-v3-first-look/</feedburner:origLink></item>
		<item>
		<title>Windows 8 Developer Preview and PowerShell v3 First Look</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/JPE8RM-ZMO0/</link>
		<comments>http://www.mikepfeiffer.net/2011/09/windows-8-developer-preview-and-powershell-v3-first-look/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 16:15:59 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[v3]]></category>
		<category><![CDATA[Windows 8]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=8194</guid>
		<description><![CDATA[This week, Microsoft is holding its BUILD conference, which shows developers whats coming in the next version of Windows. Yesterday, they released the Windows Developer Preview, which a pre-beta version of Windows 8 for developers. Now that PowerShell is part of the operating system, this also means we get a preview of PowerShell v3, and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This week, Microsoft is holding its <a href="http://www.buildwindows.com/" target="_blank">BUILD</a> conference, which shows developers whats coming in the next version of Windows. Yesterday, they released the Windows Developer Preview, which a pre-beta version of Windows 8 for developers. Now that PowerShell is part of the operating system, this also means we get a preview of PowerShell v3, and as you would probably guess, so far it is pretty impressive. The first thing I looked at was how many cmdlets were available using Get-Command. With PowerShell v2, there were 236 core cmdlets. In the Windows Developer Preview, you can see that over 100 core cmdlets have been added to the shell:</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/powershell_v3_1.png" /></p>
<p>Next, I wanted to see how many modules were included with the OS. Windows 7 included 5 or 6 PowerShell modules. In the Windows Developer Preview, there are over 230. Some of the more interesting ones I've noticed so far are dedicated to managing DNS, network adapters and TCP/IP, iSCSI, Scheduled Tasks, and Scheduled Jobs.</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/powershell_v3_2.png" target="_blank" /></p>
<p>The PowerShell ISE (Integrated Scripting Environment) has also gotten quite an upgrade. IntelliSense has been included in the script editor and input pane, in addition to a new command window that allows you to graphically compose commands by selecting a cmdlet name, and entering the parameter values into the fields beneath it.</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/powershell_v3_3.png" /></p>
<p>Honestly, I wasn't surprised to see intellisense in the ISE for cmdlets. But, I was impressed when I noticed that intellisense also works for parameter arguments. For example, in the screen shot below, you can see that I've typed <em>Get-Process -Name</em> into the script editor, and I'm given a list of available process to select:</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/powershell_v3_4.png" /></p>
<p>And finally...bracket highlighting. The lack of this basic feature really made it difficult for me to primarily use the ISE in v2, but with v3, it looks like that has been solved:</p>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/09/powershell_v3_5.png" /></p>
<p>Keep in mind that this is a very early preview, so a lot of this could change drastically in time. You can download the Windows Developer Preview from <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516" target="_blank">MSDN</a>. There are x86 and x64 versions, along with the Windows Developer Preview with developer tools, which includes Microsoft Visual Studio 11 Express, Expression Blend 5, and 28 Metro style apps including the BUILD Conference app.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/JPE8RM-ZMO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/09/windows-8-developer-preview-and-powershell-v3-first-look/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/09/windows-8-developer-preview-and-powershell-v3-first-look/</feedburner:origLink></item>
		<item>
		<title>Testing Exchange Autodiscover with PowerShell and the EWS Managed API</title>
		<link>http://feedproxy.google.com/~r/MikePfeiffer/~3/vEQHx2M2HwI/</link>
		<comments>http://www.mikepfeiffer.net/2011/08/testing-exchange-autodiscover-with-powershell-and-the-ews-managed-api/#comments</comments>
		<pubDate>Thu, 25 Aug 2011 00:08:41 +0000</pubDate>
		<dc:creator>Mike Pfeiffer</dc:creator>
				<category><![CDATA[Exchange 2010]]></category>
		<category><![CDATA[Exchange Online]]></category>
		<category><![CDATA[Exchange Web Services]]></category>
		<category><![CDATA[Office 365]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[AutoConfiguration]]></category>
		<category><![CDATA[Autodiscover]]></category>
		<category><![CDATA[E-Mail]]></category>
		<category><![CDATA[Exchange]]></category>
		<category><![CDATA[Office365]]></category>

		<guid isPermaLink="false">http://www.mikepfeiffer.net/?p=6985</guid>
		<description><![CDATA[Have you ever used that "Test E-mail AutoConfiguration" utility in Outlook? It's a useful tool that will query the autodiscover service, showing you exactly what CAS URLs are being handed to a particular user, and what the MAPI/HTTP endpoint is for their Exchange mailbox. You can run this tool by pressing the Ctrl button, right [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Have you ever used that "Test E-mail AutoConfiguration" utility in Outlook? It's a useful tool that will query the autodiscover service, showing you exactly what CAS URLs are being handed to a particular user, and what the MAPI/HTTP endpoint is for their Exchange mailbox. You can run this tool by pressing the Ctrl button, right clicking on the Outlook 2007/2010 tray icon, and selecting "Test E-mail AutoConfiguration". This is nice, but there are times when I want to be able to determine this information for a user without having to fire up Outlook, or when Outlook isn't installed where ever I happen to be at the moment. My solution for this is a PowerShell function that will retrieve this information using the EWS Managed API. Here's the code:</p>
<pre class=PowerGuiScript><span style="color: #0000FF;">function</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">Test-Autodiscover</span><span style="color: #000000;"> {
    [</span><span style="color: #0000FF;">CmdletBinding</span><span style="color: #000000;">()]
    </span><span style="color: #0000FF;">param</span><span style="color: #000000;">(
      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">1</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$true</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">String</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$EmailAddress</span><span style="color: #000000;">,</span><span style="color: #000000;">

      [</span><span style="color: #0000FF;">ValidateSet</span><span style="color: #000000;">(</span><span style="color: #800000;">"Internal"</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #800000;">"External"</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">2</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$false</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">String</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$Location</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800000;">"External"</span><span style="color: #000000;">,</span><span style="color: #000000;">      

      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">3</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$false</span><span style="color: #000000;">)]
      [</span><span style="color: #8B4513;">System.Management.Automation.PSCredential</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$Credential</span><span style="color: #000000;">,</span><span style="color: #000000;">

      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">4</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$false</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">switch</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$TraceEnabled</span><span style="color: #000000;">,</span><span style="color: #000000;">

      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">5</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$false</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">bool</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$IgnoreSsl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">$true</span><span style="color: #000000;">,</span><span style="color: #000000;">

      [</span><span style="color: #0000FF;">Parameter</span><span style="color: #000000;">(</span><span style="color: #0000FF;">Position</span><span style="color: #FF0000;">=</span><span style="color: #000000;">6</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #0000FF;">Mandatory</span><span style="color: #FF0000;">=</span><span style="color: #0000FF;">$false</span><span style="color: #000000;">)]
      [</span><span style="color: #0000FF;">String</span><span style="color: #000000;">]
      </span><span style="color: #800080;">$Url</span><span style="color: #000000;">
      )

      </span><span style="color: #0000FF;">begin</span><span style="color: #000000;">{
        </span><span style="color: #5F9EA0;">Add-Type</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">-Path</span><span style="color: #000000;"> </span><span style="color: #800000;">'</span><span style="color: #008000; text-decoration: underline;">C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll</span><span style="color: #800000;">'</span><span style="color: #000000;">
      }

      </span><span style="color: #0000FF;">process</span><span style="color: #000000;"> {
        </span><span style="color: #800080;">$autod</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">New-Object</span><span style="color: #000000;"> </span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.AutodiscoverService</span><span style="color: #000000;">
        </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">RedirectionUrlValidationCallback</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> {</span><span style="color: #0000FF;">$true</span><span style="color: #000000;">}
        </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">TraceEnabled</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$TraceEnabled</span><span style="color: #000000;">

        </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$IgnoreSsl</span><span style="color: #000000;">) {
          [</span><span style="color: #8B4513;">System.Net.ServicePointManager</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ServerCertificateValidationCallback</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> {</span><span style="color: #0000FF;">$true</span><span style="color: #000000;">}
        }

        </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$Credential</span><span style="color: #000000;">){
          </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Credentials</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">New-Object</span><span style="color: #000000;"> </span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Data.WebCredentials</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">-ArgumentList</span><span style="color: #000000;"> </span><span style="color: #800080;">$Credential</span><span style="color: #000000;">.</span><span style="color: #8B4513;">UserName</span><span style="color: #000000;">,</span><span style="color: #000000;"> </span><span style="color: #800080;">$Credential</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetNetworkCredential</span><span style="color: #000000;">()</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Password</span><span style="color: #000000;">
        }

        </span><span style="color: #0000FF;">if</span><span style="color: #000000;">(</span><span style="color: #800080;">$Url</span><span style="color: #000000;">) {
          </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Url</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$Url</span><span style="color: #000000;">
        }

        </span><span style="color: #0000FF;">switch</span><span style="color: #000000;">(</span><span style="color: #800080;">$Location</span><span style="color: #000000;">) {
          </span><span style="color: #800000;">"Internal"</span><span style="color: #000000;"> {
            </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">EnableScpLookup</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">$true</span><span style="color: #000000;">
            </span><span style="color: #800080;">$response</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetUserSettings</span><span style="color: #000000;">(
              </span><span style="color: #800080;">$EmailAddress</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalRpcClientServer</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalEcpUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalEwsUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalOABUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalUMUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">InternalWebClientUrls</span><span style="color: #000000;">
            )

            </span><span style="color: #5F9EA0;">New-Object</span><span style="color: #000000;"> </span><span style="color: #0000FF;">PSObject</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">-Property</span><span style="color: #000000;"> </span><span style="color: #000000;">@</span><span style="color: #000000;">{
              </span><span style="color: #0000FF;">RpcClientServer</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalRpcClientServer</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">InternalOwaUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalWebClientUrls</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #8B4513;">urls</span><span style="color: #000000;">[</span><span style="color: #000000;">0</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #8B4513;">url</span><span style="color: #000000;">
              </span><span style="color: #0000FF;">InternalEcpUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalEcpUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">InternalEwsUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalEwsUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">InternalOABUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalOABUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">InternalUMUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">InternalUMUrl</span><span style="color: #000000;">]
            }
          }
          </span><span style="color: #800000;">"External"</span><span style="color: #000000;"> {
            </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">EnableScpLookup</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">$false</span><span style="color: #000000;">
            </span><span style="color: #800080;">$response</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$autod</span><span style="color: #000000;">.</span><span style="color: #8B4513;">GetUserSettings</span><span style="color: #000000;">(
              </span><span style="color: #800080;">$EmailAddress</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalMailboxServer</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalEcpUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalEwsUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalOABUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalUMUrl</span><span style="color: #000000;">,</span><span style="color: #000000;">
              [</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #8B4513;">ExternalWebClientUrls</span><span style="color: #000000;">
            )

            </span><span style="color: #5F9EA0;">New-Object</span><span style="color: #000000;"> </span><span style="color: #0000FF;">PSObject</span><span style="color: #000000;"> </span><span style="color: #5F9EA0;">-Property</span><span style="color: #000000;"> </span><span style="color: #000000;">@</span><span style="color: #000000;">{
              </span><span style="color: #0000FF;">HttpServer</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalMailboxServer</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">ExternalOwaUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalWebClientUrls</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #8B4513;">urls</span><span style="color: #000000;">[</span><span style="color: #000000;">0</span><span style="color: #000000;">]</span><span style="color: #000000;">.</span><span style="color: #8B4513;">url</span><span style="color: #000000;">
              </span><span style="color: #0000FF;">ExternalEcpUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalEcpUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">ExternalEwsUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalEwsUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">ExternalOABUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalOABUrl</span><span style="color: #000000;">]
              </span><span style="color: #0000FF;">ExternalUMUrl</span><span style="color: #000000;"> </span><span style="color: #FF0000;">=</span><span style="color: #000000;"> </span><span style="color: #800080;">$response</span><span style="color: #000000;">.</span><span style="color: #8B4513;">Settings</span><span style="color: #000000;">[[</span><span style="color: #8B4513;">Microsoft.Exchange.WebServices.Autodiscover.UserSettingName</span><span style="color: #000000;">]</span><span style="color: #000000;">::</span><span style="color: #0000FF;">ExternalUMUrl</span><span style="color: #000000;">]
            }
          }
        }
      }
</span><span style="color: #008000;">&lt;#
    .</span><span style="color: #008000;">SYNOPSIS</span><span style="color: #008000;">
        </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">function</span><span style="color: #008000;"> </span><span style="color: #008000;">uses</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">EWS</span><span style="color: #008000;"> </span><span style="color: #008000;">Managed</span><span style="color: #008000;"> </span><span style="color: #008000;">API</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">test</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">Exchange</span><span style="color: #008000;"> </span><span style="color: #008000;">Autodiscover</span><span style="color: #008000;"> </span><span style="color: #008000;">service</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">DESCRIPTION</span><span style="color: #008000;">
        </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">function</span><span style="color: #008000;"> </span><span style="color: #008000;">will</span><span style="color: #008000;"> </span><span style="color: #008000;">retreive</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">Client</span><span style="color: #008000;"> </span><span style="color: #008000;">Access</span><span style="color: #008000;"> </span><span style="color: #008000;">Server</span><span style="color: #008000;"> </span><span style="color: #008000;">URLs</span><span style="color: #008000;"> </span><span style="color: #008000;">for</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">specified</span><span style="color: #008000;"> </span><span style="color: #008000;">email</span><span style="color: #008000;"> </span><span style="color: #008000;">address</span><span style="color: #008000;">
        </span><span style="color: #008000;">by</span><span style="color: #008000;"> </span><span style="color: #008000;">querying</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">autodiscover</span><span style="color: #008000;"> </span><span style="color: #008000;">service</span><span style="color: #008000;"> </span><span style="color: #008000;">of</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">Exchange</span><span style="color: #008000;"> </span><span style="color: #008000;">server</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">EmailAddress</span><span style="color: #008000;">
        </span><span style="color: #008000;">Specifies</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">email</span><span style="color: #008000;"> </span><span style="color: #008000;">address</span><span style="color: #008000;"> </span><span style="color: #008000;">for</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">mailbox</span><span style="color: #008000;"> </span><span style="color: #008000;">that</span><span style="color: #008000;"> </span><span style="color: #008000;">should</span><span style="color: #008000;"> </span><span style="color: #008000;">be</span><span style="color: #008000;"> </span><span style="color: #008000;">tested</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">Location</span><span style="color: #008000;">
        </span><span style="color: #008000;">Set</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">External</span><span style="color: #008000;"> </span><span style="color: #008000;">by</span><span style="color: #008000;"> </span><span style="color: #008000;">default</span><span style="color: #008000;">, </span><span style="color: #008000;">but</span><span style="color: #008000;"> </span><span style="color: #008000;">can</span><span style="color: #008000;"> </span><span style="color: #008000;">also</span><span style="color: #008000;"> </span><span style="color: #008000;">be</span><span style="color: #008000;"> </span><span style="color: #008000;">set</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">Internal</span><span style="color: #008000;">. </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">parameter</span><span style="color: #008000;"> </span><span style="color: #008000;">controls</span><span style="color: #008000;"> </span><span style="color: #008000;">whether</span><span style="color: #008000;">
        </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">internal</span><span style="color: #008000;"> </span><span style="color: #008000;">or</span><span style="color: #008000;"> </span><span style="color: #008000;">external</span><span style="color: #008000;"> </span><span style="color: #008000;">URLs</span><span style="color: #008000;"> </span><span style="color: #008000;">are</span><span style="color: #008000;"> </span><span style="color: #008000;">returned</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">Credential</span><span style="color: #008000;">
        </span><span style="color: #008000;">Specifies</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">user</span><span style="color: #008000;"> </span><span style="color: #008000;">account</span><span style="color: #008000;"> </span><span style="color: #008000;">that</span><span style="color: #008000;"> </span><span style="color: #008000;">has</span><span style="color: #008000;"> </span><span style="color: #008000;">permission</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">perform</span><span style="color: #008000;"> </span><span style="color: #008000;">this</span><span style="color: #008000;"> </span><span style="color: #008000;">action</span><span style="color: #008000;">. </span><span style="color: #008000;">Type</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">user</span><span style="color: #008000;"> </span><span style="color: #008000;">name</span><span style="color: #008000;">, </span><span style="color: #008000;">such</span><span style="color: #008000;"> </span><span style="color: #008000;">as</span><span style="color: #008000;">
        "</span><span style="color: #008000;">User01</span><span style="color: #008000;">" </span><span style="color: #008000;">or</span><span style="color: #008000;"> "</span><span style="color: #008000;">Domain01</span><span style="color: #008000;">\</span><span style="color: #008000;">User01</span><span style="color: #008000;">", </span><span style="color: #008000;">or</span><span style="color: #008000;"> </span><span style="color: #008000;">enter</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">PSCredential</span><span style="color: #008000;"> </span><span style="color: #008000;">object</span><span style="color: #008000;">, </span><span style="color: #008000;">such</span><span style="color: #008000;"> </span><span style="color: #008000;">as</span><span style="color: #008000;"> </span><span style="color: #008000;">one</span><span style="color: #008000;"> </span><span style="color: #008000;">from</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">Get</span><span style="color: #008000;">-</span><span style="color: #008000;">Credential</span><span style="color: #008000;"> </span><span style="color: #008000;">cmdlet</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">TraceEnabled</span><span style="color: #008000;">
        </span><span style="color: #008000;">Use</span><span style="color: #008000;"> </span><span style="color: #008000;">this</span><span style="color: #008000;"> </span><span style="color: #008000;">switch</span><span style="color: #008000;"> </span><span style="color: #008000;">parameter</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">enable</span><span style="color: #008000;"> </span><span style="color: #008000;">tracing</span><span style="color: #008000;">. </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">is</span><span style="color: #008000;"> </span><span style="color: #008000;">used</span><span style="color: #008000;"> </span><span style="color: #008000;">for</span><span style="color: #008000;"> </span><span style="color: #008000;">debugging</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">XML</span><span style="color: #008000;"> </span><span style="color: #008000;">response</span><span style="color: #008000;"> </span><span style="color: #008000;">from</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">server</span><span style="color: #008000;">.    

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">IgnoreSsl</span><span style="color: #008000;">
        </span><span style="color: #008000;">Set</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> $</span><span style="color: #008000;">true</span><span style="color: #008000;"> </span><span style="color: #008000;">by</span><span style="color: #008000;"> </span><span style="color: #008000;">default</span><span style="color: #008000;">. </span><span style="color: #008000;">If</span><span style="color: #008000;"> </span><span style="color: #008000;">you</span><span style="color: #008000;"> </span><span style="color: #008000;">do</span><span style="color: #008000;"> </span><span style="color: #008000;">not</span><span style="color: #008000;"> </span><span style="color: #008000;">want</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">ignore</span><span style="color: #008000;"> </span><span style="color: #008000;">SSL</span><span style="color: #008000;"> </span><span style="color: #008000;">warnings</span><span style="color: #008000;"> </span><span style="color: #008000;">or</span><span style="color: #008000;"> </span><span style="color: #008000;">errors</span><span style="color: #008000;">, </span><span style="color: #008000;">set</span><span style="color: #008000;"> </span><span style="color: #008000;">this</span><span style="color: #008000;"> </span><span style="color: #008000;">parameter</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> $</span><span style="color: #008000;">false</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">PARAMETER</span><span style="color: #008000;">  </span><span style="color: #008000;">Url</span><span style="color: #008000;">
        </span><span style="color: #008000;">You</span><span style="color: #008000;"> </span><span style="color: #008000;">can</span><span style="color: #008000;"> </span><span style="color: #008000;">use</span><span style="color: #008000;"> </span><span style="color: #008000;">this</span><span style="color: #008000;"> </span><span style="color: #008000;">parameter</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">manually</span><span style="color: #008000;"> </span><span style="color: #008000;">specifiy</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">autodiscover</span><span style="color: #008000;"> </span><span style="color: #008000;">url</span><span style="color: #008000;">.        

    .</span><span style="color: #008000;">EXAMPLE</span><span style="color: #008000;">
        </span><span style="color: #008000;">PS</span><span style="color: #008000;"> </span><span style="color: #008000;">C</span><span style="color: #008000;">:\&gt; </span><span style="color: #008000;">Test</span><span style="color: #008000;">-</span><span style="color: #008000;">Autodiscover</span><span style="color: #008000;"> -</span><span style="color: #008000;">EmailAddress</span><span style="color: #008000;"> </span><span style="color: #008000;">administrator</span><span style="color: #008000;">@</span><span style="color: #008000;">uclabs</span><span style="color: #008000;">.</span><span style="color: #008000;">ms</span><span style="color: #008000;"> -</span><span style="color: #008000;">Location</span><span style="color: #008000;"> </span><span style="color: #008000;">internal</span><span style="color: #008000;">

        </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">example</span><span style="color: #008000;"> </span><span style="color: #008000;">shows</span><span style="color: #008000;"> </span><span style="color: #008000;">how</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">retrieve</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">internal</span><span style="color: #008000;"> </span><span style="color: #008000;">autodiscover</span><span style="color: #008000;"> </span><span style="color: #008000;">settings</span><span style="color: #008000;"> </span><span style="color: #008000;">for</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">user</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">EXAMPLE</span><span style="color: #008000;">
        </span><span style="color: #008000;">PS</span><span style="color: #008000;"> </span><span style="color: #008000;">C</span><span style="color: #008000;">:\&gt; </span><span style="color: #008000;">Test</span><span style="color: #008000;">-</span><span style="color: #008000;">Autodiscover</span><span style="color: #008000;"> -</span><span style="color: #008000;">EmailAddress</span><span style="color: #008000;"> </span><span style="color: #008000;">administrator</span><span style="color: #008000;">@</span><span style="color: #008000;">uclabs</span><span style="color: #008000;">.</span><span style="color: #008000;">ms</span><span style="color: #008000;"> -</span><span style="color: #008000;">Credential</span><span style="color: #008000;"> $</span><span style="color: #008000;">cred</span><span style="color: #008000;">

        </span><span style="color: #008000;">This</span><span style="color: #008000;"> </span><span style="color: #008000;">example</span><span style="color: #008000;"> </span><span style="color: #008000;">shows</span><span style="color: #008000;"> </span><span style="color: #008000;">how</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">retrieve</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">external</span><span style="color: #008000;"> </span><span style="color: #008000;">autodiscover</span><span style="color: #008000;"> </span><span style="color: #008000;">settings</span><span style="color: #008000;"> </span><span style="color: #008000;">for</span><span style="color: #008000;"> </span><span style="color: #008000;">a</span><span style="color: #008000;"> </span><span style="color: #008000;">user</span><span style="color: #008000;">. </span><span style="color: #008000;">You</span><span style="color: #008000;"> </span><span style="color: #008000;">can</span><span style="color: #008000;">
        </span><span style="color: #008000;">provide</span><span style="color: #008000;"> </span><span style="color: #008000;">credentials</span><span style="color: #008000;"> </span><span style="color: #008000;">if</span><span style="color: #008000;"> </span><span style="color: #008000;">you</span><span style="color: #008000;"> </span><span style="color: #008000;">do</span><span style="color: #008000;"> </span><span style="color: #008000;">not</span><span style="color: #008000;"> </span><span style="color: #008000;">want</span><span style="color: #008000;"> </span><span style="color: #008000;">to</span><span style="color: #008000;"> </span><span style="color: #008000;">use</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">Windows</span><span style="color: #008000;"> </span><span style="color: #008000;">credentials</span><span style="color: #008000;"> </span><span style="color: #008000;">of</span><span style="color: #008000;"> </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">user</span><span style="color: #008000;"> </span><span style="color: #008000;">calling</span><span style="color: #008000;">
        </span><span style="color: #008000;">the</span><span style="color: #008000;"> </span><span style="color: #008000;">function</span><span style="color: #008000;">.

    .</span><span style="color: #008000;">LINK</span><span style="color: #008000;">
        </span><span style="color: #008000; text-decoration: underline;">http://msdn.microsoft.com/en-us/library/dd633699%28v=EXCHG.80%29.aspx</span><span style="color: #008000;">

#&gt;</span><span style="color: #000000;">
}

</span>
</pre>
<p>There are a few ways to use this Test-Autodiscover function. First, lets say that you are logged on to a domain workstation. Running the function with the following parameters will use your logged on credentials to perform an SCP look up and return the internal settings for the specified e-mail address:</p>
<pre>
Test-Autodiscover -EmailAddress administrator@uclabs.ms -Location internal
</pre>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/08/testautod_1.png" /></p>
<p>You can omit the -Location parameter, which by default is set to "External", and the function will use DNS to locate autodiscover and retrieve the external settings:</p>
<pre>
Test-Autodiscover -EmailAddress administrator@uclabs.ms
</pre>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/08/testautod_2.png" /></p>
<p>Finally, you might be testing this from the a machine outside your domain. Just create a PSCredential object using the Get-Credential cmdlet and assign it to the -Credential parameter of the function. For example, here's the result from testing autodiscover for an Exchange Online mailbox hosted through Office 365:</p>
<pre>
Test-Autodiscover -EmailAddress admin@uclabs.onmicrosoft.com -Credential $cred
</pre>
<p><img src="http://www.mikepfeiffer.net/wp-content/uploads/2011/08/test_autod3.png" /></p>
<p>In order to use this function you'll need a few things.  First, if you haven't already, go download the <a href="http://www.microsoft.com/download/en/details.aspx?id=13480" target="_blank">EWS Managed API</a>. You'll also need the .NET Framework 3.5.1 and PowerShell v2 installed. At that point, all you need to do is <a href="http://www.mikepfeiffer.net/2010/06/how-to-add-functions-to-your-powershell-session/" target="_blank">add</a> the Test-Autodiscover function to your shell session and you're good to go.</p>
<img src="http://feeds.feedburner.com/~r/MikePfeiffer/~4/vEQHx2M2HwI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.mikepfeiffer.net/2011/08/testing-exchange-autodiscover-with-powershell-and-the-ews-managed-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.mikepfeiffer.net/2011/08/testing-exchange-autodiscover-with-powershell-and-the-ews-managed-api/</feedburner:origLink></item>
	</channel>
</rss>

