<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Ashour's blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/ashour/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/ashour/feed.xml</link>
    <description>A story from the field</description>
    <lastBuildDate>Tue, 16 Apr 2019 04:42:51 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Tip of the day: isMemberOf Transpot rule is not firing</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/tip-of-the-day-ismemberof-transpot-rule-is-not-firing</link>
      <pubDate>Wed, 31 May 2017 08:42:19 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/?p=515</guid>
      <description><![CDATA[This tip is for customers running dedicated exchange and MT, though it will probably raise in hybrid...]]></description>
      <content:encoded><![CDATA[<p>This tip is for customers running dedicated exchange and MT, though it will probably raise in hybrid scenarios as well.</p> <p>In this scenario the MX record is sending the traffic to MT environment and the transport rule is based on isMemberOf.<br><br>Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : If the message:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Is sent to a member of group <a href="mailto:'allusers@contoso.com'">'allusers@contoso.com'</a>  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and Includes these words in the message subject: 'Recognition Summary'  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and Is received from 'Outside the organization'  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Take the following actions:  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Set audit severity level to 'Low'  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and Delete the message without notifying the recipient or sender  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and Stop processing more rules  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and Send the incident report to <a href="mailto:admin@contoso.com">admin@contoso.com</a>, include these message properties in the report: sender, recipients, subject, cc'd recipients,  <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bcc'd recipients, severity, sender override information, matching rules, false positive reports. <br> <p>The transport rule was firing for all group members except a single user, Alex.<br><br>Alex mailbox resides in ANSI and Exchange had no issue to resolve Alex’s external address but then fails to lookup the external address in the address book.<br><br>The address book lookup is looking for a proxy address for <a href="mailto:Alex@mgd.contoso.com">Alex@mgd.contoso.com</a> but that was missing so the solution was quite simple, add the external address to the proxy address attribute.  <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/clip_image0025.gif"><img title="clip_image002[5]" style="border-top: 0px;border-right: 0px;border-bottom: 0px;padding-top: 0px;padding-left: 0px;border-left: 0px;padding-right: 0px" border="0" alt="clip_image002[5]" src="https://msdnshared.blob.core.windows.net/media/2017/05/clip_image0025_thumb.gif" width="1135" height="1209"></a> <p>&nbsp; <p>Enjoy <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none;border-left-style: none;border-bottom-style: none;border-right-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2017/05/wlEmoticon-smile5.png"></p> <p>Ahmed Ashour</p> <p>Service Engineer II</p>]]></content:encoded>
    </item>
    <item>
      <title>Bad relationship meaning no Free/Busy</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/bad-relationship-meaning-no-freebusy</link>
      <pubDate>Sat, 27 May 2017 12:32:32 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/?p=455</guid>
      <description><![CDATA[TL;DR – if you have a bad personal relationship then you will lose free/busy :) I’ve recently worked...]]></description>
      <content:encoded><![CDATA[<p>TL;DR – if you have a bad personal relationship then you will lose free/busy :)</p> <p>I’ve recently worked with one of our o365 customers to investigate a free/busy issue not working across forest in one direction from <a href="mailto:X1@contoso.com -----x&gt; to Y1@datum.com">X1@contoso.com -----x&gt; <span style="color: #000000">to </span>Y1@datum.com</a></p> <p>It’s working for everyone else, even X1 is able to see the f/b of Y2.</p> <p>X2 who is in the same database with X1 is able to see the f/b of Y1 and Y2.</p> <p>The first and easiest way to move forward is to draw the scenario and think how we can approach the issue.</p> <p><a href="https://msdnshared.blob.core.windows.net/media/2017/05/image476.png"><img title="image" style="border-left-width: 0px;border-right-width: 0px;border-bottom-width: 0px;padding-top: 0px;padding-left: 0px;padding-right: 0px;border-top-width: 0px" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/2017/05/image_thumb436.png" width="811" height="356"></a></p> <h3>The first question to ask if the user can reproduce that in both owa and outlook and if we can have a decrypted fiddler trace from OWA.</h3> <p>Walking through the fiddler trace, here we go, the exception is:</p> <p>{"MessageText":"Proxy web request failed. , inner exception: <strong><span style="color: #ff0000">System.Net.WebException</span></strong>: The underlying connection was closed: An unexpected error occurred on a receive. ---&gt; System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---&gt; <strong><span style="color: #ff0000">System.Net.Sockets.SocketException</span></strong>: An existing connection was forcibly closed by the remote host<b><br></b></p> <p>The exception doesn’t make any sense, specially that <a href="mailto:X2@contoso.com">X2@contoso.com</a> is able to see the free/busy so we can’t really relay on that exception.<br></p> <h3>Permission issue ?</h3> <p>The default user is granted availability only permission which is what we need for organization relationship.</p> <p>We also don’t have any explicit permissions for X1 or X2.</p> <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="top" width="623">PS &gt; Get-MailboxFolderPermission -Identity <a href="mailto:Y1@datum.com:\Calendar">Y1@datum.com:\Calendar</a><br>FolderName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; User&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; AccessRights<br>----------&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ----&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ------------<br>Calendar&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Default&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {AvailabilityOnly}</td></tr></tbody></table> <p><br>To avoid ACL stale issues we moved X1 and Y1 mailbox but that didn’t change anything.</p> <h3>So what’s so special between the two users ?!</h3> <p>To answer this question I decided to take an extra trace from X1 backend server in a live session with the customer as we couldn’t find any useful data in IIS\Café Ews\EWS\event viewer logs.</p> <p>The extra trace is confirming that they have a personal relationship but what kind of personal relationship do they have ?</p> <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td valign="top" width="821">"InfoWorker.RequestDispatch","RequestRouting", Found a personal relationship for <a href="mailto:Y1@datum.com">Y1@datum.com</a></td></tr></tbody></table> <p>Looking at the source code, I found that we evaluate if there's a personal sharing between the two users and we query the f/b based on that.</p> <p>But where do we store the personal sharing data ?</p> <p>The subscription is stored as a hidden message in the folder "\root\sharing" and you can use MFCMAPI to check that.</p> <p>The subscription message class is: IPM.ExternalSharingSubscription.</p> <p>PropertyTag&nbsp;&nbsp;&nbsp; : 80C9001F<br>PropertyId&nbsp;&nbsp;&nbsp;&nbsp; : SharerIdentity:80C9:Unicode(f52a8693-c34d-4980-9e20-9d4c1eabb6a7:ExternalSharingSharerIdentity)<br>PropertyType&nbsp;&nbsp; : Unicode<br>PropertyName&nbsp;&nbsp; : f52a8693-c34d-4980-9e20-9d4c1eabb6a7:ExternalSharingSharerIdentity<br>EntryType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Value<br>SerializedSize : 32<br>CanonicalSize&nbsp; : 54<br>PropertyValue&nbsp; : <a href="mailto:Y1@datum.com">Y1@datum.com</a></p> <p>PropertyTag&nbsp;&nbsp;&nbsp; : 80C6001F<br>PropertyId&nbsp;&nbsp;&nbsp;&nbsp; : Url:80C6:Unicode(f52a8693-c34d-4980-9e20-9d4c1eabb6a7:ExternalSharingUrl)<br>PropertyType&nbsp;&nbsp; : Unicode<br>PropertyName&nbsp;&nbsp; : f52a8693-c34d-4980-9e20-9d4c1eabb6a7:ExternalSharingUrl<br>EntryType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; : Value<br>SerializedSize : 62<br>CanonicalSize&nbsp; : 114<br>PropertyValue&nbsp; : <a href="https://mail..datum.com/EWS/Exchange.asmx/WSSecurity">https://mail..datum.com/EWS/Exchange.asmx/WSSecurity</a><br><br></p> <h4>If the environment is on-premises you can leverage store query in exchange 2013\2016 instead of MFCMAPI.</h4> <p>$mbx=get-mailbox <a href="mailto:x1@contoso.com">x1@contoso.com</a><br>$mbxNumber=Get-StoreQuery -Database $($mbx.Database) -Query "Select MailboxNumber From Mailbox Where MailboxGuid = '$($mbx.ExchangeGuid)'"<br>$folders=Get-StoreQuery -Database $mbx.Database -Query "select * from Folder where MailboxPartitionNumber = '$($mbxNumber.MailboxNumber)' and DisplayName like '%Sharing%'" $messages=$folders | %{Get-StoreQuery -Database $mbx.Database -Query "select * from Message Where MailboxPartitionNumber = '$($mbxNumber.MailboxNumber)' and FolderId = '$($_.FolderId)' and MessageClass = 'IPM.ExternalSharingSubscription'" -Unlimited}<br>$blob=@(Get-StoreQuery -Database $mbx.Database -Query "Select * From ParsePropertyBlob($($messages[0].PropertyBlob), 'Message',$($mbxNumber.MailboxNumber))") $blob | where{$_.PropertyName -like '*ExternalSharing*'}</p> <p>$blob</p> <p><br>We didn’t finish yet <img class="wlEmoticon wlEmoticon-smile" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2017/05/wlEmoticon-smile4.png"></p> <h3>Does that mean that f/b will always fail if the calendar sharing is used ?</h3> <p>Let’s introduce another user in the story, X3.</p> <p>If Y1 shared her calendar with X3, X3 will automatically granted explicit permission over Y1 calendar.</p> <p>If the explicit permission is removed or missing then the f/b won’t work.<br>Sounds like we have a way to resolve the issue and a solid understanding of the root cause.</p> <p><strong></strong></p> <p><br>Enjoy <img class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="https://msdnshared.blob.core.windows.net/media/2017/05/wlEmoticon-winkingsmile.png"></p> <p>Ahmed Ashour</p> <p>Service Engineer II</p>]]></content:encoded>
    </item>
    <item>
      <title>Multi threading public folder report</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/multi-threading-public-folder-report-2</link>
      <pubDate>Thu, 05 May 2016 03:42:00 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/?p=386</guid>
      <description><![CDATA[&nbsp; Have you ever run 7 TB of data resident in public folders with over 400K folders? What if you...]]></description>
      <content:encoded><![CDATA[<p>&nbsp;</p> <p><font size="2">Have you ever run 7 TB of data resident in public folders with over 400K folders?</font></p> <p><font size="2">What if you want to generate a report that show some statistics about these folders and the permissions assigned to each folder ? do you imagine how much of time you need to complete that report ? it could take weeks to finish such a report.</font></p> <p><font size="2">What could cause such a delay ? </font></p> <p><font size="2">1- Commands are taking time to process each folder</font></p> <p><font size="2">2- Loop techniques are handling folders in serial mode<br></font><font size="2"><br>But aren’t PowerShell running in .net so why not to run in multithreading ?</font></p> <p><font size="2">Of course we need to make sure that we won’t slow down exchange by this and we won’t be throttled by the system but is it possible ?</font></p> <p><font size="2">The answer is YES if you can split the code in a way to run in parallel mode and to do that let’s see the below example and walk through the stages.</font><br></p> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><span style="color:"><font color="#006400" size="2">#Stage 0: Some global variables, you can easily change the server name or even loop in all servers from a single location<br></font></span></span><font size="2"><span><font color="#ff4500">$Svr</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">"mydeve14” <br></font></span></span></font><font size="2"><span><font color="#ff4500">$ResultSize</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">“unlimited”<br></font></span></span></font><font size="2"><span><font color="#ff4500">$Date</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-DisplayHint</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">Date<br></font></span></span></font><font size="2"><span><font color="#ff4500">$SDate</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$Date</font></span><font color="#000000">)</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">ToShortDateString() </font><span style="color:"><font color="#a9a9a9">-replace</font></span><font color="#000000">(</font><span style="color:"><font color="#8b0000">“/”</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#8b0000">”-“</font></span><font color="#000000">)</font></span></font></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span></p> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#006400" size="2">#Stage 1: get all Folder statistics from the server<br></font></span><span><font color="#ff4500" size="2">$Folders</font></span><span><font size="2"><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-PublicFolderStatistics</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Server</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Svr</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-ResultSize</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$ResultSize</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-EA</font></span><font color="#000000"> </font><span style="color:"><font color="#800080">0</font></span><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">select</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">Name</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#8a2be2">FolderPath</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">Databasename,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">CreationTime</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">Identity</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">ItemCount</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">LastUserAccessTime</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">LastUserModificationTime</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">OwnerCount</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">TotalItemSize</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">AssociatedItemCount</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font></font><span style="color:"><font color="#8a2be2" size="2">TotalAssociatedItemSize </font></span></span><span><span style="color:"><font color="#8a2be2" size="2"></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><br></p></font></span></span> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#006400" size="2">#Stage 3: We define what kind of information we want to extract from each folder inside the script block, stage 2 will be at the end</font></span><span><font color="#006400"><br></font></span><font size="2"><span><font color="#ff4500">$ScriptBlock</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> {<br></font></span></font><span><font size="2"><span style="color:"><font color="#00008b">Param</font></span><font color="#000000"> (<br></font></font></span><span><font size="2"><span style="color:"><font color="#ff4500">$Folders</font></span><span style="color:"><font color="#a9a9a9">,<br></font></span></font></span><span><font size="2"><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">int</font></span><span style="color:"><font color="#a9a9a9">]</font></span><span style="color:"><font color="#ff4500">$PageSize</font></span><span style="color:"><font color="#a9a9a9">,<br></font></span></font></span><span><font size="2"><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">int</font></span><span style="color:"><font color="#a9a9a9">]</font></span><span style="color:"><font color="#ff4500">$Offset</font></span><span style="color:"><font color="#a9a9a9">,<br></font></span></font></span><span><font size="2"><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">int</font></span><span style="color:"><font color="#a9a9a9">]</font></span><span style="color:"><font color="#ff4500">$RunNum,</font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#ff4500" size="2"><span style="color:">[string]$conn</span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"><span style="color:">)</span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"><span style="color:"></span></font></span>&nbsp;</p><span><font size="2"><span style="color:"><font color="#ff4500"> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><font size="2"><span><font color="#ff4500">$Svr</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">"mydeve14” </font></span></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><font color="#8b0000"></font><br>&nbsp;</p></font></span></font></span> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span><font color="#a9a9a9"><font style="font-size: 9pt">.</font></font></span><span><font style="font-size: 9pt"><font color="#000000"> </font><span style="color:"><font color="#8b0000">'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1'</font></span></font><span><font style="font-size: 9pt" color="#000000">&nbsp; </font></span></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span><font color="#0000ff"><font style="font-size: 9pt">connect-exchangeserver</font></font></span><span><font style="font-size: 9pt"><font color="#000000"> </font><span style="color:"><font color="#8b0000">"</font></span><span style="color:"><font color="#ff4500">$conn</font></span><span style="color:"><font color="#8b0000">.mylab.dev"</font></span><font color="#000000"> </font></font><span style="color:"><font style="font-size: 9pt" color="#000080">-allowClobber </font></span></span></font></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000"><font size="2"><span></span></font></font></span>&nbsp;</p> <blockquote><span><font color="#006400"><font size="2">#3.1 Define the log name</font></font></span> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><font size="2"><span><font color="#ff4500">$Log</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">“c:\codes\pfstate\PFStats</font></span><span style="color:"><font color="#ff4500">$SDate</font></span><span style="color:"><font color="#8b0000">-</font></span><span style="color:"><font color="#ff4500">$Svr</font></span><span style="color:"><font color="#8b0000">-</font></span><span style="color:"><font color="#ff4500">$RunNum</font></span><span style="color:"><font color="#8b0000">.txt”<br></font></span></span></font></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#006400"><font size="2"></font></font></span>&nbsp;</p> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#006400"><font size="2">#3.2 Select folders based on page size and offset<br></font></font></span><font size="2"><span><font color="#ff4500">$Folders</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folders</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">select-object</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-skip</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Offset</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-First</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$PageSize<br></font></span></span></font><span><font size="2"><span style="color:"><font color="#ff4500">$PFCnt</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folders</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">count </font><span style="color:"><font color="#006400">#Total number of folders<br></font></span></font></span><span><font size="2"><span style="color:"><font color="#8b0000">“Number of Folders: </font></span><span style="color:"><font color="#ff4500">$PFCnt</font></span><span style="color:"><font color="#8b0000">”</font></span></font></span></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><font size="2"><span><span><font color="#000000"></font></span></span></font>&nbsp;</p> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><span style="color:"><font color="#006400" size="2">#3.3 Write the log header<br></font></span></span><span><font size="2"><span style="color:"><font color="#8b0000">“</font></span><span style="color:"><font color="#ff4500">$Svr</font></span><span style="color:"><font color="#8b0000"> Public Folders as of </font></span><span style="color:"><font color="#ff4500">$Date</font></span><span style="color:"><font color="#8b0000"> Total number of Folders: </font></span><span style="color:"><font color="#ff4500">$PFCnt</font></span><span style="color:"><font color="#8b0000">”</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">&gt;</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Log<br></font></span></font></span><span><font size="2"><span style="color:"><font color="#ff4500">$now</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">DateTime</font></span><span style="color:"><font color="#a9a9a9">]::</font></span><font color="#000000">Now<br></font></font></span><span><font size="2"><span style="color:"><font color="#8b0000">“FolderName`tPath (PFID)`tDatabaseName`tItem Count`tTotal Item Size (KB)`tAssociated Item Count`tAssociated Item Size (KB)`tOldest Content`tNewest Content`tCreation Date`t Last User Access Date`tLast User Modification Date`tClient Permissions”</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">&gt;&gt;</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Log</font></span><font color="#000000"> </font><span style="color:"><font color="#006400">#File Header</font></span></font></span></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span>&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span></p> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span style="color:"><font color="#006400" size="2">#3.4 Let’s do a Foreach loop to get the item statistics for each folder <br></font></span><font size="2"><span><span style="color:"><font color="#ff4500">foreach<font color="#000000">(</font>$folder in $Folders<font color="#000000">)</font></font></span></span>{</font><span><font color="#000000"><font size="2"> <br></font></font></span><span><font color="#8b0000" size="2">"processing </font></span><span><font size="2"><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">name)</font></font><span style="color:"><font color="#8b0000" size="2">"<br></font></span></span><span style="color:"><font color="#ff4500" size="2">$Db=$Folder.DatabaseName</font></span><span><span style="color:"><font color="#8b0000"><br></font></span></span><span><font size="2"><span style="color:"><font color="#ff4500">$PFID</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">“\”</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color:"><font color="#ff4500"><font size="2">$folder.</font><font color="#000000" size="2">FolderPath <br></font></font></span></span><font size="2"><span><font color="#ff4500">$Count = <span style="color:"><font color="#ff4500"><font size="2">$folder.itemcount</font></font></span></font></span></font><span><span style="color:"><font color="#ff4500"><font color="#000000" size="2"><br></font></font></span></span><font size="2"><span><font color="#ff4500">$Size</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#800080">0</font></span><font color="#000000"> </font><span style="color:"><font color="#006400">#TotalItemSize <br></font></span></span></font><font size="2"><span><font color="#ff4500">$Size</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">TotalItemSize</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">value</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">toKB()<br></font></span></font><font size="2"><span><font color="#ff4500">$CTime</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">CreationTime</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">ToShortDateString() </font><span style="color:"><font color="#006400">#Creation Date<br></font></span></span></font><font size="2"><span><font color="#ff4500">$ATime</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#00008b">If</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">LastUserAccessTime){</font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">LastUserAccessTime</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">ToShortDateString()}<br></font></span></font><font size="2"><span><font color="#ff4500">$MTime</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#00008b">If</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">LastUserModificationTime) {</font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">LastUserModificationTime</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">ToShortDateString()}<br></font></span></font><font size="2"><span><font color="#ff4500">$AssocItemCt</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AssociatedItemCount </font><span style="color:"><font color="#006400">#Attachments?<br></font></span></span></font><font size="2"><span><font color="#ff4500">$AssocItemSize</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folder</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">TotalAssociatedItemSize</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">value</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">toKB() </font><span style="color:"><font color="#006400">#Attachment size? <br></font></span></span></font><font size="2"><span><font color="#ff4500">$Content</font></span><span><font color="#ff4500">s</font></span><span> <span style="color:"><font color="#a9a9a9">=</font></span> <span style="color:"><font color="#ff4500">$null</font></span> <span style="color:"><font color="#006400">#Dates of folder content<br></font></span></span></font><font size="2"><span><font color="#ff4500">$Oldest</font></span><span> <span style="color:"><font color="#a9a9a9">=</font></span> <span style="color:"><font color="#ff4500">$null</font></span> <span style="color:"><font color="#006400">#Date of oldest content<br></font></span></span></font><font size="2"><span><font color="#ff4500">$Newest</font></span><span> <span style="color:"><font color="#a9a9a9">=</font></span> <span style="color:"><font color="#ff4500">$null</font></span> <span style="color:"><font color="#006400">#Date of newest content <br></font></span></span></font></p> <p><span><font color="#006400"><font size="2"></font></font></span>&nbsp;</p> <p><span><font color="#006400"><font size="2">#3.4.a check the newest and oldest items<br></font></font></span><span><font color="#ff4500" size="2">$Contents</font></span><span><font size="2"><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-PublicFolderItemStatistics</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Identity</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$PFID</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Server</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Svr</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Select</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">CreationTime</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Sort</font></span><font color="#000000"> </font></font><span style="color:"><font color="#8a2be2" size="2">CreationTime <br></font></span></span><font size="2"><span><font color="#00008b">If</font></span><span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$Contents</font></span><font color="#000000">) {</font></span></font><span><font size="2"><span style="color:"><font color="#00008b">If</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$Items</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">“1”</font></span><font color="#000000">) {<br></font></font></span><span><font size="2"><span style="color:"><font color="#ff4500">&nbsp;&nbsp;&nbsp; $Oldest</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Contents</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">CreationTime </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Format</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">dd/MM/yyyy<br></font></span></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Newest</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Contents</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">CreationTime </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Format</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">dd/MM/yyyy<br></font></span></font></span><span><font size="2"><font color="#000000"><span>&nbsp;&nbsp;&nbsp; </span>} </font><span style="color:"><font color="#00008b">Else</font></span><font color="#000000"> {<br></font></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Oldest</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Contents</font></span><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#800080">0</font></span><span style="color:"><font color="#a9a9a9">].</font></span><font color="#000000">CreationTime </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Format</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">dd/MM/yyyy<br></font></span></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Newest</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Contents</font></span><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#ff4500">$Items</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">–</font></span><font color="#000000"> </font><span style="color:"><font color="#800080">1</font></span><span style="color:"><font color="#a9a9a9">].</font></span><font color="#000000">CreationTime </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Get-Date</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Format</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">dd/MM/yyyy<br></font></span></font></span><span><font color="#000000"><font size="2"><span>&nbsp;&nbsp;&nbsp; </span>} </font></font></span><span><font color="#000000" size="2">}<br></font></span><span><font color="#000000"><br><span style="color:"><font color="#006400" size="2">#3.4.b Let’s check the client permissions for each folder<br></font></span></font></span><font size="2"><span><font color="#ff4500">$Perm</font></span><span><font color="#a9a9a9">=</font></span><span><font color="#ff4500">$null<br></font></span></font><font size="2"><span><font color="#0000ff">Get-PublicFolderClientPermission</font></span><span><font color="#000000"> </font><span style="color:"><font color="#000080">-Identity</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$PFID</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-Server</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Svr</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">Select</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">User</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000">@{Name</font><span style="color:"><font color="#a9a9a9">=</font></span><span style="color:"><font color="#8b0000">'AccessRights'</font></span><font color="#000000">;Expression</font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000">{</font><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">string</font></span><span style="color:"><font color="#a9a9a9">]::</font></span><font color="#000000">join(</font><span style="color:"><font color="#8b0000">', '</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$_</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AccessRights)}} </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">%</font></span><font color="#000000">{</font><span style="color:"><font color="#ff4500">$Perm</font></span><span style="color:"><font color="#a9a9a9">+=</font></span><span style="color:"><font color="#8b0000">"</font></span><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$_</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">User)</font><span style="color:"><font color="#8b0000">#</font></span><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$_</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AccessRights)</font><span style="color:"><font color="#8b0000">;"</font></span><font color="#000000">}<br></font></span></font><font size="2"><span><font color="#ff4500">$Perm</font></span><span><font color="#a9a9a9">.</font></span><span><font color="#000000">TrimEnd(</font><span style="color:"><font color="#8b0000">";"</font></span><font color="#000000">) <br><br></font></span></font><span><font color="#006400" size="2">#3.4.c Output to log file</font></span><span><span><font color="#000000" size="2">&nbsp; </font></span></span><font size="2"><span><font color="#000000"><br></font></span></font><span><font size="2"><span style="color:"><font color="#8b0000">“</font></span><span style="color:"><font color="#ff4500">$Name</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$PFID</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$Db</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$Count</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$Size</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$AssocItemCt</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$AssocItemSize</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$Oldest</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$Newest</font></span><span style="color:"><font color="#8b0000">`t</font></span><span style="color:"><font color="#ff4500">$CTime<span style="color:"><font color="#8b0000">`t<font size="2"><span><font color="#ff4500">$ATime</font></span><span><font color="#000000"> </font></span></font><span style="color:"><font color="#8b0000">`t<font size="2"><span><font color="#ff4500">$MTime</font></span><span><font color="#000000"> </font></span></font></font></span><span style="color:"><font color="#8b0000">`t<font size="2"><span><font color="#ff4500">$Perm</font></span></font></font></span></font></span></font></span><span style="color:"><font color="#8b0000">”</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">&gt;&gt;</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Log</font></span></font></span><font size="2"><span><span><font color="#000000"><br></font></span></span></font><font size="2"><font color="#000000"><span><br>} </span></font><span><font color="#006400">#Ending the loop</font></span></font><span><font color="#8a2be2" size="2">&nbsp; <br></font></span><font size="2"><span><font color="#0000ff">Get-Date</font></span><span><font color="#000000"> </font><span style="color:"><font color="#000080">-Format</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">g</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">&gt;&gt;</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Log <br></font></span></span></font><font size="2"><span><font color="#000000">} </font></span><span><font color="#006400">#Ending the script block</font></span></font><font size="2"><span><font color="#006400"></p></blockquote> <blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"># Stage 2: Let’s start the funny part to spawn multiple threads, we create as much threads as we want # to handle 1000 threads, </font></span><span><font color="#006400">you may need to check PowerShell throttling policy so that you have # no limits for your </font></span></font><span><font color="#006400" size="2">admin account running this script<br>#2.1: Set the pagesize and the number of threads we need, we limit the threads to 4 to avoid impacting CPU</font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span style="font-family:;color:"><font color="#ff4500"><font style="font-size: 9pt">$Offset</font></font></span><font style="font-size: 9pt"><span style="font-family:;color:"><font color="#a9a9a9">=</font></span><span style="font-family:;color:"><font color="#800080">0</font></span></font><span style="font-family:"><font style="font-size: 9pt" color="#000000">;</font></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span style="font-family:;color:"><font color="#ff4500"><font style="font-size: 9pt">$numThreads</font></font></span><span style="font-family:"><font style="font-size: 9pt"><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font></font><span style="color:"><font style="font-size: 9pt" color="#800080">3</font></span></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:;color:"><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#check if the division has remainder or we will have an int number # +1 as we start with thread 0 and that results on 4 thread 0,1,2,3</font></font></span><span style="font-family:"></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span style="font-family:;color:"><font color="#a9a9a9"><font style="font-size: 9pt">[</font></font></span><font style="font-size: 9pt"><span style="font-family:;color:"><font color="#008080">int</font></span><span style="font-family:;color:"><font color="#a9a9a9">]</font></span><span style="font-family:;color:"><font color="#ff4500">$remainder</font></span></font><span style="font-family:"><font style="font-size: 9pt"><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folders</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">count </font><span style="color:"><font color="#a9a9a9">%</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$numThreads</font></span><span style="color:"><font color="#a9a9a9">+</font></span><span style="color:"><font color="#800080">1</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">&nbsp;</font></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:;color:"><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">#int number to avoid decimals, also change the pagsize to by dynamic based on the number of folders and the threads we intend to run</font></font></span><span style="font-family:"></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><font face="Lucida Console"><span style="font-family:;color:"><font color="#a9a9a9"><font style="font-size: 9pt">[</font></font></span><font style="font-size: 9pt"><span style="font-family:;color:"><font color="#008080">int</font></span><span style="font-family:;color:"><font color="#a9a9a9">]</font></span><span style="font-family:;color:"><font color="#ff4500">$PageSize</font></span></font><span style="font-family:"><font style="font-size: 9pt"><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$Folders</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">count </font><span style="color:"><font color="#a9a9a9">/</font></span><font color="#000000"> (</font><span style="color:"><font color="#ff4500">$numThreads</font></span><span style="color:"><font color="#a9a9a9">+</font></span><span style="color:"><font color="#800080">1</font></span><font color="#000000">)</font></font></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><font size="2"><span><font color="#ff4500"><font color="#333333"><br></font></font></span></font>&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#006400" size="2">#2.2: create the powershell runspace <br></font></span><font size="2"><span><font color="#ff4500">$myString</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">"this is session state!"<br></font></span></span></font><font size="2"><span><font color="#ff4500">$sessionState</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">System.Management.Automation.Runspaces.InitialSessionState</font></span><span style="color:"><font color="#a9a9a9">]::</font></span><font color="#000000">CreateDefault()<br></font></span></font><font size="2"><span><font color="#ff4500">$sessionstate</font></span><span><font color="#a9a9a9">.</font></span><span><font color="#000000">Variables</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">Add((</font><span style="color:"><font color="#0000ff">New-Object</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-TypeName</font></span><font color="#000000"> </font><span style="color:"><font color="#8a2be2">System.Management.Automation.Runspaces.SessionStateVariableEntry</font></span><font color="#000000"> </font><span style="color:"><font color="#000080">-ArgumentList</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">"myString"</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#ff4500">$myString</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#8b0000">"session state"</font></span><font color="#000000">))<br></font></span></font><font size="2"><span><font color="#ff4500">$RunspacePool</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">RunspaceFactory</font></span><span style="color:"><font color="#a9a9a9">]::</font></span><font color="#000000">CreateRunspacePool(</font><span style="color:"><font color="#800080">1</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> 4</font><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$sessionState</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$host</font></span><font color="#000000">)<br></font></span></font><font size="2"><span><font color="#ff4500">$RunspacePool</font></span><span><font color="#a9a9a9">.</font></span><span><font color="#000000">Open()</font></span></font></p><font size="2"><span><font color="#000000"> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><br></font></span></font><span><font color="#006400" size="2">#2.3 Start numThreads threads each on a dedicated server and increase the offset</font></span></p> <p><a href="mailto:$servers=@(&quot;server01&quot;,&quot;server02&rdquo;,&rdquo;server03&rdquo;,&rdquo;server04">$servers=@("server01","server02”,”server03”,”server04”)</a><span><font color="#006400" size="2"><br></font></span><font size="2"><span><font color="#800080">0</font></span><span><font color="#a9a9a9">..</font></span><span><font color="#ff4500">$numThreads</font></span><span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">|</font></span><font color="#000000"> </font><span style="color:"><font color="#0000ff">%</font></span><font color="#000000"> {</font></span></font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></font><span style="color:"><font style="font-size: 9pt" color="#006400">#Increase the last thread with the remainder</font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></font><font style="font-size: 9pt"><span style="color:"><font color="#00008b">if</font></span><font color="#000000">(</font><span style="color:"><font color="#ff4500">$_</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">-eq</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$numThreads</font></span><font color="#000000">)</font></font></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">&nbsp;&nbsp;&nbsp; {</font></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></font><font style="font-size: 9pt"><span style="color:"><font color="#ff4500">$PageSize</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$PageSize</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">+</font></span><font color="#000000"> </font></font><span style="color:"><font style="font-size: 9pt" color="#ff4500">$remainder</font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font style="font-size: 9pt" color="#000000">&nbsp;&nbsp;&nbsp; }<br></font></font></span><font size="2"><span><font color="#000000"><br></font></span></font><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#8b0000">"Start at offset </font></span><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$Offset</font></span><font color="#000000">)</font><span style="color:"><font color="#8b0000"> till </font></span><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$Offset</font></span><span style="color:"><font color="#a9a9a9">+</font></span><span style="color:"><font color="#ff4500">$PageSize</font></span><font color="#000000">)</font><span style="color:"><font color="#8b0000">"<br></font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:;color:"><font face="Lucida Console"><font style="font-size: 9pt" color="#006400"></font></font></span>&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:;color:"><font face="Lucida Console"><font style="font-size: 9pt" color="#006400">&nbsp;&nbsp;&nbsp; #Due to processing issues, we are running each thread in a dedicated server</font></font></span><span style="font-family:"></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></font><font style="font-size: 9pt"><span style="color:"><font color="#ff4500">$Conn</font></span><span style="color:"><font color="#a9a9a9">=</font></span><span style="color:"><font color="#ff4500">$servers</font></span><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#ff4500">$_</font></span></font><span style="color:"><font style="font-size: 9pt" color="#a9a9a9">]</font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span style="font-family:"><font face="Lucida Console"><font color="#000000"><font style="font-size: 9pt">&nbsp;&nbsp;&nbsp; </font></font><font style="font-size: 9pt"><span style="color:"><font color="#8b0000">"Will connect to </font></span><font color="#000000">$(</font><span style="color:"><font color="#ff4500">$conn</font></span><font color="#000000">)</font></font><span style="color:"><font style="font-size: 9pt" color="#8b0000">"</font></span></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt;line-height: normal"><span><font size="2"><span style="color:"><font color="#8b0000"><br></font></span></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Job</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#a9a9a9">[</font></span><span style="color:"><font color="#008080">powershell</font></span><span style="color:"><font color="#a9a9a9">]::</font></span><font color="#000000">Create()</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AddScript(</font><span style="color:"><font color="#ff4500">$ScriptBlock</font></span><font color="#000000">)</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AddParameter(</font><span style="color:"><font color="#8b0000">"Folders"</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#ff4500">$Folders</font></span><font color="#000000">)</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AddParameter(</font><span style="color:"><font color="#8b0000">"Offset"</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#ff4500">$Offset</font></span><font color="#000000">)</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AddParameter(</font><span style="color:"><font color="#8b0000">"PageSize"</font></span><span style="color:"><font color="#a9a9a9">,</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$PageSize</font></span><font color="#000000">)</font><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">AddParameter(</font><span style="color:"><font color="#8b0000">"RunNum"</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#ff4500">$_</font></span><font color="#000000">)<font face="Lucida Console"><span style="font-family:;color:"><font color="#a9a9a9"><font style="font-size: 9pt">.</font></font></span><span style="font-family:"><font style="font-size: 9pt">AddParameter(<span style="color:"><font color="#8b0000">"conn"</font></span><span style="color:"><font color="#a9a9a9">,</font></span><span style="color:"><font color="#ff4500">$conn</font></span>)</font></span></font><br></font></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Job</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">RunspacePool </font><span style="color:"><font color="#a9a9a9">=</font></span><font color="#000000"> </font><span style="color:"><font color="#ff4500">$RunspacePool<br></font></span></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Job</font></span><span style="color:"><font color="#a9a9a9">.</font></span><font color="#000000">BeginInvoke()<br></font></font></span><span><font size="2"><span><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span><span style="color:"><font color="#ff4500">$Offset</font></span><span style="color:"><font color="#a9a9a9">+=</font></span><span style="color:"><font color="#ff4500">$PageSize<br></font></span></font></span><span><font color="#000000" size="2">} </font></span></p></blockquote> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000"></font></span><font size="2">Upon testing running in multi thread was able to retrieve the results for 26k from a single server in less than 1 hour while the normal foreach loop in a single thread last for more than 7 days and didn’t finish the job.</font></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt">&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt">&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2">Enjoy <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none;border-left-style: none;border-bottom-style: none;border-right-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/2016/05/wlEmoticon-smile1.png"></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2"></font></span>&nbsp;</p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2">Ahmed Ashour</font></span></p> <p class="MsoNormal" style="background: white;margin: 0in 0in 0pt"><span><font color="#000000" size="2">Support Escalation Engineer</font></span></p>  <p>&nbsp;</p> <p>&nbsp;</p> <p># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. # MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR # A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL # MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, # BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE # SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION # OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>]]></content:encoded>
    </item>
    <item>
      <title>Tip of the day: Where are the delivery restriction settings for resource mailboxes ?</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/tip-of-the-day-where-are-the-delivery-restriction-settings-for-resource-mailboxes</link>
      <pubDate>Thu, 05 May 2016 01:12:53 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/?p=311</guid>
      <description><![CDATA[If you moved from exchange 2010 to 2013 SP1 you will notice that you are no more able to see the...]]></description>
      <content:encoded><![CDATA[If you moved from exchange 2010 to 2013 SP1 you will notice that you are no more able to see the message delivery restriction settings in ECP for resource mailboxes, they are gone <img class="wlEmoticon wlEmoticon-sadsmile" style="border-style: none" src="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/4544.wlEmoticon_2D00_sadsmile_5F00_140DCB65.png" alt="Sad smile" />
<p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="color: #000000;font-size: medium">But hold on, the feature is not removed, it’s just the ECP no more showing the options.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="font-size: medium"><span style="color: #000000">You still can manage the message delivery restriction using exchange shell.</span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="color: #000000;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt"><span style="font-size: medium"><span style="color: #000000">Set-Mailbox can do the job with the parameters “</span><span style="color: #000000"><span style="color: #000000">–AcceptMessagesOnlyFrom”, “-</span>AcceptMessagesOnlyFromDLMembers”, “-RequireSenderAuthenticationEnabled”, “-RejectMessagesFrom “,“-RejectMessagesFromDLMembers”, </span></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium">This example configures the mailbox of Azure Meeting Room to accept messages only from the users Lori Penor, Jeff Phillips, and members of the distribution group Legal Team 1.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #0000ff;font-size: medium">Set-Mailbox -Identity "Azure Meeting Room" -AcceptMessagesOnlyFrom "Lori Penor","Jeff Phillips" -AcceptMessagesOnlyFromDLMembers "Legal Team 1"</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium">This example adds the user named David Pelton to the list of users whose messages will be accepted by the resource mailbox.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #0000ff;font-size: medium">Set-Mailbox -Identity "Azure Meeting Room" -AcceptMessagesOnlyFrom @{add="David Pelton"}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium">This example configures the resource mailbox to require all senders to be authenticated. This means the mailbox will only accept messages sent by other users in your Exchange organization.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #0000ff;font-size: medium">Set-Mailbox -Identity "Azure Meeting Room" -RequireSenderAuthenticationEnabled $true</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium">This example configures the resource mailbox to reject messages from the users Joe Healy, Terry Adams, and members of the distribution group Legal Team 2.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #0000ff;font-size: medium">Set-Mailbox -Identity "Azure Meeting Room" -RejectMessagesFrom "Joe Healy","Terry Adams" -RejectMessagesFromDLMembers "Legal Team 2"</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.5pt"><span style="color: #2a2a2a;font-size: medium">This example configures the resource mailbox reject messages sent by members of the group Legal Team 3.</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #0000ff;font-size: medium">Set-Mailbox -Identity "Azure Meeting Room" -RejectMessagesFromDLMembers @{add="Legal Team 3"}</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #000000;font-size: medium">Enjoy <img class="wlEmoticon wlEmoticon-smile" style="border-style: none" src="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/7041.wlEmoticon_2D00_smile_5F00_080BDB31.png" alt="Smile" /></span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="font-size: medium"> </span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #000000;font-size: medium">Ahmed Ashour</span></p>
<p class="MsoNormal" style="margin: 0in 0in 0pt;line-height: 13.15pt"><span style="color: #000000;font-size: medium">Support Escalation Engineer</span></p>]]></content:encoded>
    </item>
    <item>
      <title>Tip of the Day: How to force the max message size for cloud users</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/tip-of-the-day-how-to-force-the-max-message-size-for-cloud-users</link>
      <pubDate>Fri, 28 Aug 2015 14:22:25 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2015/08/28/tip-of-the-day-how-to-force-the-max-message-size-for-cloud-users/</guid>
      <description><![CDATA[&#160;  If you are running a hybrid setup and your company policy is forcing max message size of...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p><font size="3">If you are running a hybrid setup and your company policy is forcing max message size of 10mb then how you can force cloud users not to send more than 10mb ?</font></p>  <p><font size="3">It’s not just that the cloud users can send more than 15mb emails, they also will have NDRs from the on-prem servers if they send internal communication more than 15mb.</font></p>  <p><font size="3">Changing the max send size or receive size is not something you can achieve in the cloud even if you escalated to the product group and the Microsoft support however you can create a transport rule in the office365 portal to drop any emails that has an attachment larger than or equal 15mb</font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3582.clip_image00110_1DB153AC.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3582.clip_5F00_image00110_5F00_1DB153AC.jpg"><img title="clip_image001[10]" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image001[10]" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/2234.clip_image00110_thumb_7D2CA4AA.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/2234.clip_5F00_image00110_5F00_thumb_5F00_7D2CA4AA.jpg" width="813" height="267" /></a></p>  <p><font size="3"></font></p>  <p><font size="3">Enjoy <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Winking smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/1614.wlEmoticon-winkingsmile_60B2437B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/1614.wlEmoticon_2D00_winkingsmile_5F00_60B2437B.png" /></font></p>  <p><font size="3">Ahmed Ashour     <br />Support Escalation Engineer</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Tip of the Day: How to limit SMTP applications to send from a specific mailbox</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/tip-of-the-day-how-to-limit-smtp-applications-to-send-from-a-specific-mailbox</link>
      <pubDate>Fri, 28 Aug 2015 12:50:26 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2015/08/28/tip-of-the-day-how-to-limit-smtp-applications-to-send-from-a-specific-mailbox/</guid>
      <description><![CDATA[&#160;  It’s easy to allow an smtp application to send emails through your exchange servers but it’s...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p><font size="3">It’s easy to allow an smtp application to send emails through your exchange servers but it’s not easy to force the application admin to use a certain sender address.</font></p>  <p><font size="3">The receive connectors doesn’t provide such feature but you still have the option to create a transport rule to check the header and reject the email unless it’s coming from the desired mailbox.</font></p>  <p><font size="4"></font></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/1616.clip_image002_5380CC06.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/1616.clip_5F00_image002_5F00_5380CC06.jpg"><img title="clip_image002" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; padding-top: 0px; padding-left: 0px; border-left: 0px; display: inline; padding-right: 0px" border="0" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/6443.clip_image002_thumb_641DE856.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/6443.clip_5F00_image002_5F00_thumb_5F00_641DE856.jpg" width="683" height="596" /></a></p>  <p>&#160;</p>  <p><font size="3">Enjoy <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Winking smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/0184.wlEmoticon-winkingsmile_5D4C8C72.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/0184.wlEmoticon_2D00_winkingsmile_5F00_5D4C8C72.png" /></font></p>  <p><font size="3">Ahmed Ashour     <br />Support Escalation Engineer</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Fix duplication in default folders KB3031133 &amp; KB3069501 &amp; kb2991934</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/fix-duplication-in-default-folders-kb3031133-kb3069501-kb2991934</link>
      <pubDate>Fri, 28 Aug 2015 05:46:21 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2015/08/28/fix-duplication-in-default-folders-kb3031133-kb3069501-kb2991934/</guid>
      <description><![CDATA[&#160;  In exchange 2013 prior to CU9, if you migrate your mailbox to exchange 2013 you might see...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p><font size="3">In exchange 2013 prior to CU9, if you migrate your mailbox to exchange 2013 you might see duplicates in the default folders</font></p>  <p><font size="3">The same issue you may face if you are moving the mailbox from one server to another server using the –IgnoreRuleLimitErrors switch</font></p>  <p><font size="3">The update will fix the issue for new migration/mailbox move and our job is to fix it for the migrated/moved mailboxes <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/6011.wlEmoticon-smile_6E20C713.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/6011.wlEmoticon_2D00_smile_5F00_6E20C713.png" /></font></p>  <p><font size="3">The ultimate objective is to move old items to the new default folders and after that delete the folders</font></p>  <p><strong><font size="3">Let’s take that a bit by bit:</font></strong></p>  <p><font size="3">1- The new default folder is empty and old data is stored in the old folder which is no more a default</font></p>  <p><font size="3">2- You can delete the old folder</font></p>  <p><font size="3">3- The new default folder usually have the same name suffixed with 1/2/3, for example drafts1 or drafts2</font></p>  <p><font size="3">So far, it’s doable to check the WellKnownFolderName and see which one is default and which one is not the default but we still have more details yet to cover <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Winking smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3175.wlEmoticon-winkingsmile_4838F795.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3175.wlEmoticon_2D00_winkingsmile_5F00_4838F795.png" /></font></p>  <p><font size="3">4- In some cases if the default language used to be French, the new default folder change to English      <br />for example, the brouillons folder change to be drafts</font></p>  <p><font size="3">This point forced me to rethink and reconsider to write a map in the folder names for different languages.      <br />As I was working with a French customer I will share the French map and you can follow the same if you have the same symptoms.</font></p>  <p><font size="3">The source folder is the French folder and the target is the one with English, you can apply any combination you want.</font></p>  <p><font size="3">folderlist.csv      <br />&quot;Source&quot;,&quot;Target&quot;,&quot;Type&quot;       <br />&quot;Calendrier&quot;,&quot;Calendar&quot;,&quot;Default&quot;       <br />&quot;Contacts&quot;,&quot;Contacts&quot;,&quot;Default&quot;       <br />&quot;boîte de réception&quot;,&quot;Inbox&quot;,&quot;Default&quot;       <br />&quot;brouillons&quot;,&quot;Drafts&quot;,&quot;Default&quot;       <br />&quot;Journal&quot;,&quot;Journal&quot;,&quot;Default&quot;       <br />&quot;tâches&quot;,&quot;Tasks&quot;,&quot;Default&quot;       <br />&quot;courrier indésirable&quot;,&quot;JunkEmail&quot;,&quot;Default&quot;       <br />&quot;boîte d'envoy&quot;,&quot;sent items&quot;,&quot;Default&quot;       <br />&quot;éléments supprimés&quot;,&quot;deleted items&quot;,&quot;Default&quot;       <br />&quot;RSS Feeds&quot;,&quot;RSS Feeds1&quot;,&quot;Search&quot;</font></p>  <p><font size="3">5- Some folders are created by outlook and are duplicated also after the move and are not default folders, like the “RSS Feeds”      <br />if you want to change that you can add them to the list and change the type to “search”</font></p>  <p><font size="3">6- What about Folder Names ?</font></p>  <p><font size="3"><em>Outlook.exe</em> /<em>ResetFolderNames<strong> </strong></em>is the best way to get the folders back to the default name after we delete the old folders for sure.       <br />That will change the folder to the default settings in your computer, so if you run it from a computer with French language you will have Calendrier instead of Calendar for example.</font></p>  <p><strong><font size="3">Now, let’s talk about the script.</font></strong></p>  <p><font size="3">The script will move all old items from the old folders to the new default folders and once that completed, the script will remove the old folders.     <br />      <br />You need impersonation or full access rights to all mailboxes you would like to fix</font></p>  <p><font size="3">The script will ask you to provide a csv file with the list of mailboxes in the following format</font></p>  <p><font size="3">Identity      <br /></font><a href="mailto:TestE15sv05@myzoo.dev"><font size="3">TestE15sv05@myzoo.dev</font></a></p>  <p><strong><font size="3">Example:</font></strong></p> <font size="3">.\Fix-DefaulltFolders.ps1 -UseAutodiscover $false -UseDefaultCredentials $true -EwsUrl </font><a href="https://mye15cas01.mylab.dev/ews/exchange.asmx"><font size="3">https://mye15cas01.mylab.dev/ews/exchange.asmx</font></a><font size="3"> -Verbose -CsvFile ListOfMbx.csv    <br /></font>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; border-left: rgb(149,149,149) 1px solid; widows: 1; margin: 10px 2px; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&lt;#&#160; <br />.SYNOPSIS&#160; <br />Fix-DefaultFolders.ps1</p>    <p>     <br />.DESCRIPTION       <br />&#160;&#160;&#160; You need to be assigned full mailbox access or impersonation permissions before you can run this script.       <br />&#160;&#160;&#160; Moving mailboxes using “-IgnoreRuleLimitErrors” will cause duplicate folders, issue is descriped on kb/2991934       <br />&#160;&#160;&#160; The duplicate folders are created with different languages       <br />&#160;&#160;&#160; This script will move all items from the old folders to the new default folders       <br />&#160;&#160;&#160; The script will delete the old folder if it has 0 items.       <br />.NOTES&#160; <br />&#160;&#160;&#160; Author&#160;&#160;&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160; Ahmed Ashour - ahmed.ashour@hotmail.fr       <br />&#160;&#160;&#160; Creation Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; v0.1 08 June 2015       <br />&#160;&#160;&#160; Last Update&#160; :&#160;&#160;&#160;&#160;&#160; v0.4 02 July 2015       <br />&#160;&#160;&#160; Update&#160;&#160;&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160; Add the ability to fix the RSS Feeds based on Search       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Remove duplicates for working set and conversation action settings       <br />&#160;&#160;&#160; Customer&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ------------------       <br />&#160;&#160;&#160; Ticket Ref&#160;&#160; :&#160;&#160;&#160;&#160;&#160;&#160;&#160; ------------------</p>    <p>#&#160; DISCLAIMER:      <br /># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.       <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR       <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL       <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,       <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE       <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION       <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>    <p>.PARAMETER CsvFile      <br />The input csv File with primary smtp addresses</p>    <p>.PARAMETER EWSURL      <br />The EWS URL set in exchange</p>    <p>.PARAMETER Impersonate      <br />The default value is [bool]$Impersonate = $false       <br />Use this parameter if you have a service account that can impersonate multiple mailboxes</p>    <p>.PARAMETER UseAutodiscover      <br />The default value is [bool] -UseAutodiscover = $true       <br />If you have issues with autodiscover you can need to set the parameter to $false and use the EWSURL paraemter.</p>    <p>.PARAMETER UseDefaultCredentials      <br />The default value is [bool] -UseDefaultCredentials = $true       <br />If you need to run the script with any other credintials other than the loggedn in powershell user, then you need to set this parameter to $false       <br />and provide the other username, password and domain parameters</p>    <p>.PARAMETER UserName      <br />UserName that will be used for authentication       <br />The userName for O365 has to be the complete UPN.</p>    <p>.PARAMETER Password      <br />Passowrd that will be used for authentication</p>    <p>.PARAMETER Domain      <br />The AD domain name that will be used for authentication if you are running onpremise enviroment only.</p>    <p>.PARAMETER Delete      <br />Delete the Old Folders</p>    <p>.Example</p>    <p>.\Fix-DefaulltFolders.ps1 -UseAutodiscover $false -UseDefaultCredentials $false -EwsUrl <a href="https://mye15cas01.mylab.dev/ews/exchange.asmx">https://mye15cas01.mylab.dev/ews/exchange.asmx</a> -Username TestE15Mbx01@mylab.dev -Password Passowrd1 -Verbose -CsvFile ListOfMbx.csv       <br />Run the script for all users in the csv file to move the items from the old folders to the new default folders.</p>    <p>.\Fix-DefaulltFolders.ps1 -UseAutodiscover $false -UseDefaultCredentials $false -EwsUrl <a href="https://mye15cas01.mylab.dev/ews/exchange.asmx">https://mye15cas01.mylab.dev/ews/exchange.asmx</a> -Username TestE15Mbx01@mylab.dev -Password Passowrd1 -Verbose -CsvFile ListOfMbx.csv -delete $True       <br />Run the script for all users in the csv file to move the items from the old folders to the new default folders and delete the old one.       <br />#&gt;&#160; <br />[CmdletBinding(SupportsShouldProcess=$true )]       <br />param (       <br />&#160;&#160;&#160; [Parameter(Mandatory=$True,HelpMessage=&quot;Specifies the input csv file to be accessed&quot;)]       <br />&#160;&#160;&#160; [ValidateNotNullOrEmpty()]       <br />&#160;&#160;&#160; [string]$CsvFile,       <br />&#160;&#160;&#160; [bool]$Impersonate = $false,       <br />&#160;&#160;&#160; [bool]$UseAutodiscover = $true,       <br />&#160;&#160;&#160; [bool]$UseDefaultCredentials = $true,       <br />&#160;&#160;&#160; [bool]$TrustAllCertificates = $true,       <br />&#160;&#160;&#160; [bool]$Delete = $False,       <br />&#160;&#160;&#160; [string] $Username,       <br />&#160;&#160;&#160; [string] $Password,       <br />&#160;&#160;&#160; [string] $Domain,       <br />&#160;&#160;&#160; [string]$EwsUrl       <br />)</p>    <p>     <br />#Common variables       <br />[string]$EWSManagedApiPath = &quot;C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll&quot;       <br />#[string]$EWSManagedApiPath = &quot;C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll&quot;       <br />$DateStamp = Get-Date -f &quot;dd-MM-yyyy&quot;       <br />$OutFile=&quot;Results-&quot;+$DateStamp+&quot;.csv&quot;</p>    <p>if ($TrustAllCertificates -eq $true)      <br />{       <br />&#160;&#160;&#160; ## Code From <a href="https://poshcode.org/624">https://poshcode.org/624</a>       <br />&#160;&#160;&#160; ## Create a compilation environment       <br />&#160;&#160;&#160; $Provider=New-Object Microsoft.CSharp.CSharpCodeProvider       <br />&#160;&#160;&#160; $Compiler=$Provider.CreateCompiler()       <br />&#160;&#160;&#160; $Params=New-Object System.CodeDom.Compiler.CompilerParameters       <br />&#160;&#160;&#160; $Params.GenerateExecutable=$False       <br />&#160;&#160;&#160; $Params.GenerateInMemory=$True       <br />&#160;&#160;&#160; $Params.IncludeDebugInformation=$False       <br />&#160;&#160;&#160; $Params.ReferencedAssemblies.Add(&quot;System.DLL&quot;) | Out-Null       <br />&#160; <br />$TASource=@'       <br />&#160; namespace Local.ToolkitExtensions.Net.CertificatePolicy{       <br />&#160;&#160;&#160; public class TrustAll : System.Net.ICertificatePolicy {       <br />&#160;&#160;&#160;&#160;&#160; public TrustAll() {       <br />&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160; public bool CheckValidationResult(System.Net.ServicePoint sp,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Security.Cryptography.X509Certificates.X509Certificate cert,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Net.WebRequest req, int problem) {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; return true;       <br />&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />&#160; }       <br />'@       <br />&#160; <br />&#160;&#160;&#160; $TAResults=$Provider.CompileAssemblyFromSource($Params,$TASource)       <br />&#160;&#160;&#160; $TAAssembly=$TAResults.CompiledAssembly       <br />&#160; <br />&#160;&#160;&#160; ## We now create an instance of the TrustAll and attach it to the ServicePointManager       <br />&#160;&#160;&#160; $TrustAll = $TAAssembly.CreateInstance(&quot;Local.ToolkitExtensions.Net.CertificatePolicy.TrustAll&quot;)       <br />&#160;&#160;&#160; [System.Net.ServicePointManager]::CertificatePolicy = $TrustAll       <br />&#160;&#160;&#160; write-host -ForegroundColor Yellow &quot;Trusting all certificates!&quot;       <br />}       <br />&#160;</p>    <p># Loading ManagedAPI dll      <br />[Void] [Reflection.Assembly]::LoadFile($EWSManagedApiPath)       <br />&#160; <br /># Setting up the service       <br />$Service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2013_SP1);</p>    <p># Setting up credentials      <br />if ($UseDefaultCredentials -eq $true)       <br />{       <br />&#160;&#160;&#160; $Service.UseDefaultCredentials = $true;       <br />}       <br />else       <br />{&#160; <br />&#160;&#160;&#160; $Service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials($UserName, $Password, $Domain);       <br />}       <br />&#160;</p>    <p>#Function to process the folders      <br />Function ProcessFolders()       <br />{       <br />param($Folder)       <br />&#160;&#160;&#160; $Source=$folder.source       <br />&#160;&#160;&#160; $Target=$folder.Target       <br />&#160;&#160;&#160; $type=$folder.Type       <br />&#160;&#160;&#160; Write-verbose &quot;processing $($Source) &amp; $($target)&quot;       <br />&#160;&#160;&#160; $View = New-Object&#160; Microsoft.Exchange.WebServices.Data.FolderView(1000);       <br />&#160;&#160;&#160; #$View.Traversal = [Microsoft.Exchange.WebServices.Data.FolderTraversal]::Deep       <br />&#160;&#160;&#160; $SearchFilterCollection = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::OR)       <br />&#160;&#160;&#160; $SearchSource = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$Source);       <br />&#160;&#160;&#160; $SearchTarget = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,$Target);       <br />&#160;&#160;&#160; $SearchFilterCollection.Add($SearchSource)       <br />&#160;&#160;&#160; $SearchFilterCollection.Add($SearchTarget)       <br />&#160;&#160;&#160; $SourceList=@()       <br />&#160;&#160;&#160; $SearchFolders = $RootFolder.FindFolders($SearchFilterCollection,$view)       <br />&#160;&#160;&#160; if($SearchFolders)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($FolderObj in $SearchFolders)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Folder: $($FolderObj.displayName) : will check if it's default&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FolderProps = New-Object -TypeName Microsoft.Exchange.WebServices.Data.PropertySet(       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [Microsoft.Exchange.WebServices.Data.BasePropertySet]::IdOnly,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [Microsoft.Exchange.WebServices.Data.FolderSchema]::WellKnownFolderName,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [Microsoft.Exchange.WebServices.Data.FolderSchema]::FolderClass,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [Microsoft.Exchange.WebServices.Data.FolderSchema]::totalcount       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; )</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #if($Folder.WellKnownFolderName.length -lt 1)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($type -eq &quot;Search&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Default=$False       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Display=$FolderObj.displayName       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FolderObj.displayName = &quot;Del-$($FolderObj.displayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FolderObj.update();       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch [exception]       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.Exception.Message       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.Exception.Message | out-file -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Default=$True       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #if($Folder.FolderClass)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($Default)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FolderObj.displayName = $Display;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Default folder: $($FolderObj.displayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Default folder: $($FolderObj.displayName) : the default folder&quot; | Out-File -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $TargetFolder=$FolderObj&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SourceList+=$FolderObj       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Custom folder: $($FolderObj.displayName) : will add it to the source List&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Custom folder: $($FolderObj.displayName) : will add it to the source List&quot; | out-file -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service, $FolderObj.Id, $FolderProps)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #$Folder.FolderClass       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Folder.WellKnownFolderName.length       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Folder.WellKnownFolderName       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($Folder.WellKnownFolderName.length -eq 1)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Default folder: $($FolderObj.displayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Default folder: $($FolderObj.displayName)&quot; | out-file -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $TargetFolder=$FolderObj&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $SourceList+=$FolderObj       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Custom folder: $($FolderObj.displayName) : will add it to the source List&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found Custom folder: $($FolderObj.displayName) : will add it to the source List&quot; | out-file -Append $outfile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;#if($Folder.FolderClass)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Found $($FolderObj.displayName) to be the Target folder&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $TargetFolder=$Folder       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #&gt;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; #Stage 2 move the items      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; #if($SourceList -and $TargetFolder)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; #{       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #$SourceList       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Start moving To: $($TargetFolder.DisplayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach($SourceFolder in $SourceList)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Start moving from: $($SourceFolder.displayName) To: $($TargetFolder.DisplayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Start moving from: $($SourceFolder.displayName) To: $($TargetFolder.DisplayName)&quot; | out-file -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #Set parameters - we will process in batches of 1000 for the FindItems call       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Offset=0;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $PageSize=500;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ItemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView($PageSize, $Offset, [Microsoft.Exchange.Webservices.Data.OffsetBasePoint]::Beginning);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ItemView.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::IdOnly);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; do{&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FindResults=$SourceFolder.FindItems($ItemView);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ForEach ($Item in $FindResults.Items)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Item.Move($TargetFolder.Id) | Out-Null;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch [Exception]       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.exception       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Host &quot;Failed to move item&quot;, $Item.Id.UniqueId -foregroundcolor Red       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ItemView.Offset+=$FindResults.Items.Count&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Offset+=$PageSize       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;The new offset is: $($ItemView.Offset)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }while($FindResults.MoreAvailable -eq $true)</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #Stage3:Delete the old folder      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($delete -eq $True)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($SourceFolder.totalcount -eq 0)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Try       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; [void]$SourceFolder.Delete( [Microsoft.Exchange.WebServices.Data.DeleteMode]::SoftDelete )       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Deleting : $($SourceFolder.displayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Deleting : $($SourceFolder.displayName)&quot; | Out-File -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch [Exception]       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.Exception.Message       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.Exception.Message | out-file -append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;skipping the delete: $($SourceFolder.displayName) : $($SourceFolder.totalcount)&quot; | out-file -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;skipping the delete: $($SourceFolder.displayName)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; #}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; }       <br />&#160;&#160;&#160; else       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;couldn't find any folders&quot;       <br />&#160;&#160;&#160; }&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />}</p>    <p>&#160; <br />#Import List Of mailboxes       <br />$ListOfMbx=import-csv $CsvFile       <br />&quot;$($DateStamp)&quot; | Out-File $OutFile</p>    <p>If($ListOfMbx)      <br />{       <br />&#160;&#160;&#160; Foreach($Mailbox in $ListOfMbx)       <br />&#160;&#160;&#160; {</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; # Connect to the mailboxes      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; # If we are using impersonation then setup impersonation       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ($Impersonate)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Service.ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $Mailbox.identity)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; # Setting Autodiscover settings      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if ($UseAutodiscover -eq $true)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $service.AutodiscoverUrl($Mailbox, {$True});       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Service.Url = new-Object Uri($EwsUrl);       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-host &quot;Accessing mailbox $($Mailbox.identity)&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Accessing mailbox $($Mailbox.identity)&quot; | Out-File -append $OutFile</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; #Get root folder      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot,$($Mailbox.identity))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Try       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $RootFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Sucessfull authentication to mailbox $($Mailbox.identity)&quot; | Out-File -append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Go=$True       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Catch [Exception]       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.exception.message       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $_.exception.message | Out-File -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Go=$False       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($Go -eq $true)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $FoldersList=import-csv folderslist.csv -Encoding Unicode       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ForEach($Folder in $FoldersList)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ProcessFolders $Folder      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;==============================&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Error &quot;you need FullAccess permissions in order to proceed&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;you need FullAccess permissions in order to proceed&quot; | Out-File -Append $OutFile       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />}</p> </div>  <p>Enjoy <img class="wlEmoticon wlEmoticon-winkingsmile" style="border-top-style: none; border-left-style: none; border-bottom-style: none; border-right-style: none" alt="Winking smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3175.wlEmoticon-winkingsmile_4838F795.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3175.wlEmoticon_2D00_winkingsmile_5F00_4838F795.png" />    <br />    <br />Ahmed Ashour    <br />Support Escalation Engineer</p>]]></content:encoded>
    </item>
    <item>
      <title>The untold story of “Use serial migration to migrate public folders to Exchange 2013 from previous versions”</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/the-untold-story-of-use-serial-migration-to-migrate-public-folders-to-exchange-2013-from-previous-versions</link>
      <pubDate>Wed, 11 Feb 2015 14:12:18 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2015/02/11/the-untold-story-of-use-serial-migration-to-migrate-public-folders-to-exchange-2013-from-previous-versions/</guid>
      <description><![CDATA[&#160;  Today I would like to share some secrets that you have to know when you try to migrate your...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>Today I would like to share some secrets that you have to know when you try to migrate your public folders to the modern public folders following the famous article <a title="https://technet.microsoft.com/en-us/library/jj150486(v=exchg.150).aspx" href="https://technet.microsoft.com/en-us/library/jj150486(v=exchg.150).aspx">https://technet.microsoft.com/en-us/library/jj150486(v=exchg.150).aspx</a></p>  <p>I will focus mainly in four type of errors that I’ve seen repeated frequently during the migration for many customers.</p>  <p>If you follow the steps on the article everything should go through until you start the step 5 where the migration request start.</p>  <p>I will quickly explain three related issues that you may face with mail enabled public folder and normal public folders before we start developing the solution</p>  <p>1- The migration request will start to check every public folder and check the alias property before moving to exchange 2013.</p>  <p>If any special character in the alias found then the migration will throw an exception and won’t process any further folders.</p>  <p>FailureCode&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : -2146233088    <br />FailureType&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : DataValidationException     <br />FailureSide&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : Target     <br />Message&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; : <font color="#ff0000">Error: Property expression &quot;AAL Ahmed ,22/6/98 &quot; isn't valid. Valid values      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; are: Strings formed with characters from A to Z (uppercase or lowercase), digits       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; from 0 to 9, !, #, $, %, &amp;, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; periods may be embedded in an alias, but each period should be preceded and       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; followed by at least one of the other characters. Unicode characters from U+00A1 to       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; U+00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string in the e-mail address, which is generated from such an alias.</font></p>  <p>2- When it tried to change the alias I discovered that some public folders has leading or trailing whitespaces in the Name property.</p>  <p><font color="#ff0000">WARNING: The property value is invalid. The value can't contain leading or trailing whitespace.</font></p>  <p><font color="#000000">It’s possible to change the Name and Alias using set-MailPublicFolder but that is something that you can do when the data validation is OK and you are changing from a valid properties to another valid properties like you change the name from Test01 to Test001 but when you have a trailer whitespace the set-MailPublicFolder will throw the validation exceptions and you won’t be able to use it to change anything.      <br /></font><font color="#000000">The command Set-PublicFolder in the other hand don’t perform data validation so we need to change the name first before we can check the alias and change it.</font></p>  <p><font color="#000000">3- The last issue I faced is the wrong proxy addresses in some mail enabled folders.      <br /></font><font color="#000000"><font color="#ff0000">WARNING: The primary SMTP address, &quot;SMTP:A.H.N.@mylab.dev&quot;, is not valid.</font></font></p>  <p><font color="#000000">Again that will block the set-MailPublicFolder command from changing the alias, so we need to run a proxy address script to fix all wrong proxy addresses and after that we can change the alias and the name properties.</font></p>  <p>Let’s start then with the proxy addresses script:</p>  <p>Starting from Exchange 2010, if you have some legacy old smtp addresses that are not valid, exchange will save the information into</p>  <p>$Email.ParseException and your job will be to check if you have any exception and remove it using set-mailpublicFolder </p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&quot;Importing the public folders to the memory&quot;      <br />$listOfPublicFolders=import-csv publicFolders.csv       <br />foreach($Folder in $listOfPublicFolders)       <br />{&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Start working on $($Folder.identity)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $PFFolder=Get-MailPublicFolder $($Folder.identity)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found the folder $($PFFolder.identity)&quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($PFFolder)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-progress -activity &quot;Remove Wrong Proxy Addresses &quot; -status &quot;Currently processing the PF(alias) : $Folder.Alias&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $EmailAddresses=$PFFolder.EmailAddresses       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Email in $EmailAddresses)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If($Email.ParseException)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Warning &quot;$($PFFolder.alias)#Remove#$($Email.proxyaddressstring)&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set-mailpublicfolder -identity $PFFolder.alias -alias $($NewAlias) -emailaddresses @{remove=$($Email.proxyaddressstring)}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error[0].Exception       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160; </p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finished working on $($Folder.identity)&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;-------------------------------------------&quot;       <br />}</p> </div>  <p>After we correct the wrong smtp addresses, it’s time to correct the alias and the name properties.</p>  <p>This time I decided to generate a report will all aliases that has a special characters or exceeding 64 char.</p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>Function RegexSearchAndReplace      <br />{       <br />param($Test)</p>    <p>     <br />$SpechilaChars = ',','!', '&quot;', '$', '%', '&amp;', '^', '*', '(', ')', '@', '=', '+', '¬', '`', '\', '&lt;', '&gt;', '.', '?', '/', ':', ';', '#', '~', &quot;'&quot;,' ' | % {[regex]::escape($_)}</p>    <p>$OrFiltering = [string]::join('|',$SpechilaChars)</p>    <p>     <br />&#160;&#160;&#160; if(select-string -inputobject $test&#160; -Pattern $OrFiltering -AllMatches)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidAlias=$test -replace $OrFiltering, &quot;&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160; }       <br />&#160;&#160;&#160; else       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidAlias=&quot;No Change&quot;       <br />&#160;&#160;&#160; }       <br />&#160;&#160;&#160; return $ValidAlias       <br />}</p>    <p>     <br />&quot;Importing the public folders to the memory&quot;       <br />$listOfPublicFolders=import-csv pflist.csv       <br />&quot;Identity#Oldalias#ValidAlias&quot; | Out-File aliasChange.txt&#160;&#160; <br />foreach($Folder in $listOfPublicFolders)       <br />{&#160; <br />&#160;&#160;&#160; &quot;Start working on $($Folder.alias)&quot;       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $alias=$Folder.alias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($alias.length -gt 64)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-progress -activity &quot;Checking the publicFolders &quot; -status &quot;Exceeding 64Char: PF(alias) : $alias&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($alias)#Exceedin 64&quot; | Out-File -append aliasexceeding64-03.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidAlias=RegexSearchAndReplace $alias      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidAlias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($ValidAlias -eq &quot;No Change&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-progress -activity &quot;Checking the PublicFolders &quot; -status &quot;No Change needed:PF(alias) : $alias&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-progress -activity &quot;Checking the PublicFolders &quot; -status &quot;Spechial char found:PF(alias) : $alias&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($Folder.identity)#$($alias)#$($ValidAlias)&quot; | out-file -append aliasChange.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; &quot;Finished working on $($Folder.identity)&quot;       <br />&#160;&#160;&#160; &quot;-------------------------------------------&quot;       <br />}</p> </div>  <p>The next step is to change the alias based on the file from the previous step</p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&quot;Importing the public folders to the memory&quot;      <br />$listOfPublicFolders=import-csv aliasChange.txt -Delimiter &quot;#&quot;       <br />foreach($Folder in $listOfPublicFolders)       <br />{&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Start working on $($Folder.oldalias)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $OldAlias=$Folder.OldAlias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Newalias=$Folder.ValidAlias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-progress -activity &quot;Change the Alias &quot; -status &quot;Currently processing the PF(alias) : $Folder.OldAlias&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $PFFolder=Get-MailPublicFolder $OldAlias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Found the folder $($PFFolder.alias)&quot;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $PFFolder | set-MailPublicFolder -alias $($NewAlias) -ea silentlycontinue -EmailAddressPolicyEnabled:$false       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error[0].Exception       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Switch -wildcard ($Error[0].Exception)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;*The primary SMTP address*&quot; {$Error.Clear();Write-Warning &quot;Wrong SMTP $($Error[0].Exception)&quot;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;*The value can't contain leading or trailing whitespace*&quot; {$Error.Clear();Write-Warning &quot;Found Spaces $($PFFolder.name)&quot;; $PFFolder | Set-PublicFolder -Name $PFFolder.Name.tostring().trim();set-MailPublicFolder -identity $($Folder.Identity) -alias $($NewAlias) -ea silentlycontinue -EmailAddressPolicyEnabled:$false}&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Default {&quot;$($OldAlias)#$($Error[0].Exception)&quot;}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; </p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finished working on $($Folder.identity)&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;-------------------------------------------&quot;       <br />}</p> </div>  <p>We didn’t finish yet <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3223.wlEmoticon-smile_03186287.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3223.wlEmoticon_2D00_smile_5F00_03186287.png" /></p>  <p>Public folder migration will surprise you with a new error <font color="#ff0000">Fatal error TooManyLargeItemsPermanentException has occurred.</font></p>  <p><font color="#000000">The bottom line for this issue is to change the maxSendSize to a higher number, but the question is how to know this number.</font></p>  <p><font color="#000000">The migration report will report all large items so you can check them and found the large item size.</font></p>  <p><font color="#000000">The other option is to generate a report will all items in the public folders and check the largest message size</font></p>  <p><font color="#000000">Get-PublicFolder –recurse –resultsize unlimited | get-publicfolderitemstatistics | select subject,publicfoldername,messagesize </font></p>  <p>#&#160; DISCLAIMER:   <br /># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.    <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR    <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL    <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,    <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE    <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION    <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>]]></content:encoded>
    </item>
    <item>
      <title>Mail Enabled Public Folders In A Hybrid Deployment: A Sad Story</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/mail-enabled-public-folders-in-a-hybrid-deployment-a-sad-story</link>
      <pubDate>Tue, 13 Jan 2015 02:03:46 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2015/01/13/mail-enabled-public-folders-in-a-hybrid-deployment-a-sad-story/</guid>
      <description><![CDATA[&#160;  The scenario that I will discuss today is not really a fancy one.  The story began with...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>The scenario that I will discuss today is not really a fancy one.</p>  <p>The story began with exchange on premise and a hybrid deployment where public folders are migrated to the Office365, 90% of users are migrated to the cloud.</p>  <p>The main question is how to make the mail enabled public folders appear in the on premise GAL and on the office365 GAL.</p>  <p>We already know that DirSync process won’t synchronize mail enabled public folders from the cloud to the on premise environment, that’s a fact.</p>  <p>The only options is to create a mail enabled contact in the on premise environment et voila <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3108.wlEmoticon-smile_632D185D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3108.wlEmoticon_2D00_smile_5F00_632D185D.png" /></p>  <p>Sounds quick easy and achievable <strong><font size="3">BUT</font> </strong>real life will carry more complicity with other staffs like distribution groups.</p>  <p>In our scenario all distribution Groups were created originally in the on premise and are synched to the cloud, let’s call them Cloud Groups.</p>  <p>The issue here is that you can’t add cloud folders directly to the group because the group was originally created in the on premise</p>  <p>If we try to add the mail contact to the on premise group, the contact will appear to the on premise users but will never appear as a member to the cloud users.</p>  <p>Ouch, what shall we do then?</p>  <p>I would think of two options however I won’t say I like any of them but those are what we have unfortunately:</p>  <p>1- Mirror the distribution Groups using a script and keep evaluating the membership.</p>  <p>2- Recreate all the distribution groups in the office365 as 90% of users are already in cloud.</p>  <p>In this article we will cover the second option unfortunately <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3108.wlEmoticon-smile_632D185D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3108.wlEmoticon_2D00_smile_5F00_632D185D.png" /></p>  <p>There are many things to cover here:</p>  <p>1- Handle email addresses + LegacyExchangeDN(X500)</p>  <p>2- Handle Multi Value attributes and convert them from&#160; distinguishedName to Email address</p>  <blockquote>   <p>2.a GrantSendOnBehalfTo</p> </blockquote>  <blockquote>   <p>2.b ManagedBy</p> </blockquote>  <blockquote>   <p>2.c ModeratedBy</p> </blockquote>  <blockquote>   <p>2.d AcceptMessagesOnlyFromSendersOrMembers</p> </blockquote>  <blockquote>   <p>2.e BypassModerationFromSendersOrMembers</p> </blockquote>  <blockquote>   <p>2.f RejectMessagesFromSendersOrMembers</p> </blockquote>  <p>3- Handle SendAs and SendOnBehalf permissions</p>  <p>4- Handle group membership</p>  <p>5- Handle single value attributes that can be set in the Office365</p>  <p>They are defined in the script in the array <a href="mailto:$Listofsingleprops=@(&quot;BypassNestedModerationEnabled&quot;,&quot;MemberJoinRestriction&quot;,&quot;MemberDepartRestriction&quot;,&quot;ReportToManagerEnabled&quot;,&quot;ReportToOriginatorEnabled&quot;,&quot;SendOofMessageToOriginatorEnabled&quot;,&quot;HiddenFromAddressListsEnabled&quot;,&quot;ModerationEnabled&quot;,&quot;RequireSenderAuthenticationEnabled&quot;,&quot;SendModerationNotifications&quot;,&quot;CustomAttribute1&quot;,&quot;CustomAttribute10&quot;,&quot;CustomAttribute11&quot;,&quot;CustomAttribute12&quot;,&quot;CustomAttribute13&quot;,&quot;CustomAttribute14&quot;,&quot;CustomAttribute15&quot;,&quot;CustomAttribute2&quot;,&quot;CustomAttribute3&quot;,&quot;CustomAttribute4&quot;,&quot;CustomAttribute5&quot;,&quot;CustomAttribute6&quot;,&quot;CustomAttribute7&quot;,&quot;CustomAttribute8&quot;,&quot;CustomAttribute9&quot;,&quot;DisplayName&quot;,&quot;Alias&quot;,&quot;PrimarySmtpAddress&quot;,&quot;SimpleDisplayName&quot;,&quot;MailTip"><font color="#0066dd">$Listofsingleprops</font></a></p>  <p>I skipped some properties that can’t be changed in office365 like &quot;MaxSendSize&quot;,&quot;MaxReceiveSize&quot;</p>  <p><font color="#333333"><strong>As the process is a bit complex, I decided to split it into several stages so that it’s also possible to use </strong></font></p>  <p><font color="#333333"><strong>the same process to recreate distribution groups in a different forest.</strong></font></p>  <p><b>Stage 0: One time configuration</b></p>  <p>1- Create a new OU in active directory “NoDirSync”</p>  <p>2- Exclude this OU form the DirSync configuration</p>  <p><b>Stage1: Preparation</b></p>  <p>I developed a script to export all the desired informed to a csv file, the prepare-DGToOffice365.ps1 script.</p>  <p>1- This script will export the following attributes in addition to the group membership and the sendAs permission</p>  <p>$listOfprops=@(&quot;SamAccountName&quot;,&quot;EmailAddresses&quot;,&quot;ManagedBy&quot;,&quot;AcceptMessagesOnlyFrom&quot;,&quot;AcceptMessagesOnlyFromDLMembers&quot;,</p>  <p>&quot;AcceptMessagesOnlyFromSendersOrMembers&quot;,&quot;BypassModerationFromSendersOrMembers&quot;,</p>  <p>&quot;ModeratedBy&quot;,&quot;RejectMessagesFrom&quot;,&quot;RejectMessagesFromDLMembers&quot;,</p>  <p>&quot;RejectMessagesFromSendersOrMembers&quot;,&quot;GrantSendOnBehalfTo&quot;,&quot;BypassNestedModerationEnabled&quot;,</p>  <p>&quot;MemberJoinRestriction&quot;,&quot;MemberDepartRestriction&quot;,&quot;ReportToManagerEnabled&quot;,</p>  <p>&quot;ReportToOriginatorEnabled&quot;,&quot;SendOofMessageToOriginatorEnabled&quot;,&quot;HiddenFromAddressListsEnabled&quot;,</p>  <p>&quot;ModerationEnabled&quot;,&quot;RequireSenderAuthenticationEnabled&quot;,&quot;SendModerationNotifications&quot;,&quot;Alias&quot;,</p>  <p>&quot;CustomAttribute1&quot;,&quot;CustomAttribute10&quot;,&quot;CustomAttribute11&quot;,&quot;CustomAttribute12&quot;,</p>  <p>&quot;CustomAttribute13&quot;,&quot;CustomAttribute14&quot;,&quot;CustomAttribute15&quot;,&quot;CustomAttribute2&quot;,</p>  <p>&quot;CustomAttribute3&quot;,&quot;CustomAttribute4&quot;,&quot;CustomAttribute5&quot;,&quot;CustomAttribute6&quot;,&quot;CustomAttribute7&quot;,</p>  <p>&quot;CustomAttribute8&quot;,&quot;CustomAttribute9&quot;,&quot;DisplayName&quot;,&quot;MaxSendSize&quot;,</p>  <p>&quot;MaxReceiveSize&quot;,&quot;PrimarySmtpAddress&quot;,&quot;SimpleDisplayName&quot;,&quot;MailTip&quot;) </p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&lt;#&#160; <br />.SYNOPSIS&#160; <br />Use the Prepare-DGToOffice365.ps1 script to export the distribution groups information to csv file</p>    <p>     <br />.DESCRIPTION       <br />&#160;&#160;&#160; The ultimate objective is to delete all distribution groups from exchange on-premise and create them in the Office365 cloud.       <br />&#160;&#160;&#160; This sample script is the 1st script to export the distribution groups information from exchange on-premise       <br />&#160;&#160;&#160; </p>    <p>.NOTES&#160; <br />&#160;&#160;&#160; Author&#160;&#160;&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160; Ahmed Ashour - ahmed.ashour@hotmail.fr       <br />&#160;&#160;&#160; Creation Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; v1.0 4 Jan 2015       <br />&#160;&#160;&#160; Last Update&#160; :&#160;&#160;&#160;&#160;&#160; -----------------       <br />#&#160; DISCLAIMER:       <br /># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.       <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR       <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL       <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,       <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE       <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION       <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>    <p>.PARAMETER GroupName      <br />If the group name is not specified the script will export all the informations for all distribution groups</p>    <p>.PARAMETER OrganizationUnit      <br />You need to specify the NoDirSyn Organization unit that on premise distribution groups will be temporary moved to in order to stop the dirsync for those groups</p>    <p>.PARAMETER Verbose      <br />Enabled verbose logging</p>    <p>.Example</p>    <p>.\Prepare-DGToOffice365.ps1 -OrganizationUnit NoDirSync      <br />This will export the information for all distribution group and move them all to the NoDirSync organization unit</p>    <p>.\Prepare-DGToOffice365.ps1 -GroupName &quot;testDG01&quot;      <br />This will export the information for the group testdg01 and move it to the NoDirSync organization unit</p>    <p>.\Prepare-DGToOffice365.ps1 -GroupName &quot;testDG01&quot; -verbose      <br />This will export the information for the group testdg01, move it to the NoDirSync organization unit and enable verbose logging</p>    <p>.OUTPUTS      <br />Results will be saved to export.csv       <br />Errors will be saved to errors.txt</p>    <p>#&gt;&#160; </p>    <p>[CmdletBinding(SupportsShouldProcess=$true)]      <br />Param(       <br />[parameter(mandatory=$false)]$GroupName,       <br />[parameter(mandatory=$True)]$OrganizationUnit       <br />)       <br />$ExportArray=@()       <br />$ValueToStr=&quot;&quot;       <br />$DateStamp = Get-Date -f &quot;hh:mm-dd-MM-yyyy&quot;       <br />import-module activedirectory       <br />#Change the following line to search for all groups or a specific group       <br />if($GroupName)       <br />{       <br />&#160;&#160;&#160; $ListOfGroups=get-distributiongroup -identity $GroupName -ResultSize unlimited       <br />}       <br />else       <br />{       <br />&#160;&#160; $ListOfGroups=get-distributiongroup -ResultSize unlimited       <br />}</p>    <p>&quot;-------------------------Start: Prepare-DGToOffice365 Script $($DateStamp)--------------------------------&quot; | out-file -append errors.txt      <br />if($ListOfGroups)       <br />{       <br />&#160;&#160;&#160; Foreach($Group in $ListOfGroups)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;processing $($Group)&quot;       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $listOfprops=@(&quot;SamAccountName&quot;,&quot;EmailAddresses&quot;,&quot;ManagedBy&quot;,&quot;AcceptMessagesOnlyFrom&quot;,&quot;AcceptMessagesOnlyFromDLMembers&quot;,&quot;AcceptMessagesOnlyFromSendersOrMembers&quot;,&quot;BypassModerationFromSendersOrMembers&quot;,&quot;ModeratedBy&quot;,&quot;RejectMessagesFrom&quot;,&quot;RejectMessagesFromDLMembers&quot;,&quot;RejectMessagesFromSendersOrMembers&quot;,&quot;GrantSendOnBehalfTo&quot;,&quot;BypassNestedModerationEnabled&quot;,&quot;MemberJoinRestriction&quot;,&quot;MemberDepartRestriction&quot;,&quot;ReportToManagerEnabled&quot;,&quot;ReportToOriginatorEnabled&quot;,&quot;SendOofMessageToOriginatorEnabled&quot;,&quot;HiddenFromAddressListsEnabled&quot;,&quot;ModerationEnabled&quot;,&quot;RequireSenderAuthenticationEnabled&quot;,&quot;SendModerationNotifications&quot;,&quot;Alias&quot;,&quot;CustomAttribute1&quot;,&quot;CustomAttribute10&quot;,&quot;CustomAttribute11&quot;,&quot;CustomAttribute12&quot;,&quot;CustomAttribute13&quot;,&quot;CustomAttribute14&quot;,&quot;CustomAttribute15&quot;,&quot;CustomAttribute2&quot;,&quot;CustomAttribute3&quot;,&quot;CustomAttribute4&quot;,&quot;CustomAttribute5&quot;,&quot;CustomAttribute6&quot;,&quot;CustomAttribute7&quot;,&quot;CustomAttribute8&quot;,&quot;CustomAttribute9&quot;,&quot;DisplayName&quot;,&quot;MaxSendSize&quot;,&quot;MaxReceiveSize&quot;,&quot;PrimarySmtpAddress&quot;,&quot;SimpleDisplayName&quot;,&quot;MailTip&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfsingleprops=@(&quot;SamAccountName&quot;,&quot;BypassNestedModerationEnabled&quot;,&quot;MemberJoinRestriction&quot;,&quot;MemberDepartRestriction&quot;,&quot;ReportToManagerEnabled&quot;,&quot;ReportToOriginatorEnabled&quot;,&quot;SendOofMessageToOriginatorEnabled&quot;,&quot;Alias&quot;,&quot;CustomAttribute1&quot;,&quot;CustomAttribute10&quot;,&quot;CustomAttribute11&quot;,&quot;CustomAttribute12&quot;,&quot;CustomAttribute13&quot;,&quot;CustomAttribute14&quot;,&quot;CustomAttribute15&quot;,&quot;CustomAttribute2&quot;,&quot;CustomAttribute3&quot;,&quot;CustomAttribute4&quot;,&quot;CustomAttribute5&quot;,&quot;CustomAttribute6&quot;,&quot;CustomAttribute7&quot;,&quot;CustomAttribute8&quot;,&quot;CustomAttribute9&quot;,&quot;DisplayName&quot;,&quot;HiddenFromAddressListsEnabled&quot;,&quot;MaxSendSize&quot;,&quot;MaxReceiveSize&quot;,&quot;ModerationEnabled&quot;,&quot;PrimarySmtpAddress&quot;,&quot;RequireSenderAuthenticationEnabled&quot;,&quot;SimpleDisplayName&quot;,&quot;SendModerationNotifications&quot;,&quot;MailTip&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $GroupToStr = New-Object PSObject       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $GroupToStr | Add-Member NoteProperty -Name &quot;Name&quot; -Value $Group.Name       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; #1-Handle Members       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;processing membership&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $listOfMembers=(Get-DistributionGroupMember -Identity $Group.DisplayName | where{$_.recipienttype -eq &quot;UserMailbox&quot; -or $_.recipientType -eq &quot;MailUniversalDistributionGroup&quot;}) #Flash:only mailbox + Groups       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($listOfMembers)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach($Member in $listOfMembers)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr+&quot;;&quot;+(Get-recipient $Member.DistinguishedName).PrimarySmtpAddress.tostring()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr.trimstart(&quot;;&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-warning &quot;No members&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=&quot;Null&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $GroupToStr | Add-Member NoteProperty -Name &quot;Members&quot; -Value $ValueToStr</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; ######################Handle Properties#################################      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($prop in $Listofprops)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;processing $($prop)&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=&quot;&quot;&#160;&#160;&#160; </p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if([string]::IsNullOrEmpty($group.$($prop)))      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-warning &quot;Null value for $($prop)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=&quot;Null&quot;</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Switch($prop)      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #2-Handle email addresses &amp; X500       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; EmailAddresses {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;processing email addresses&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ProxyAddresses=$Group.EmailAddresses -split &quot;;&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $X500Address=&quot;X500:&quot;+&quot;$($Group.LegacyExchangeDN)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ProxyAddresses+=$X500Address       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=&quot;&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Address in $ProxyAddresses)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr+&quot;;&quot;+$Address       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr.trimstart(&quot;;&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #3-Handle Single-Values      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {$ListOfsingleprops -icontains $prop} {write-verbose &quot;single prop $($prop)&quot;;$ValueToStr=$Group.$($prop)}</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #4-Handle Multi-Values      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Default {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Found Multi $($prop)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=&quot;&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; foreach($AdMember in $Group.$($prop))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr+&quot;;&quot;+(Get-recipient $AdMember.DistinguishedName).PrimarySmtpAddress.tostring()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr.trimstart(&quot;;&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }&#160;&#160;&#160; <br />&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #5-Populate the PSObject properties      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $GroupToStr | Add-Member NoteProperty -Name $prop -Value $ValueToStr       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; #6-Handle SendAs permission      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;prcoessing sendAs permisisons&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; [String]$ValueToStr=&quot;&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfPermissions=$group| Get-ADPermission | where{($_.Isinherited -eq $false) -and ($_.extendedrights -like &quot;*Send-As*&quot;)}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($ListOfPermissions)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Assignee in $ListOfPermissions)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr+&quot;;&quot;+(Get-recipient $Assignee.User.ToString()).PrimarySmtpAddress.tostring()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToStr=$ValueToStr.trimstart(&quot;;&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $GroupToStr | Add-Member NoteProperty -Name &quot;sendAs&quot; -Value $ValueToStr       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; #7-Add Group to the export array       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ExportArray += $GroupToStr       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finsihed $($Group)&quot;</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; #8-Move the Group to the NoDirSync OU      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Moving the Group to the $($OrganizationUnit)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; $NoDirSyncOU=Get-OrganizationalUnit $OrganizationUnit       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($NoDirSyncOU)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Move-ADObject $Group.DistinguishedName -TargetPath $NoDirSyncOU.DistinguishedName       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($Group)#Move#Couldn't find the NoDirSync $($OrganizationUnit)&quot;| out-file -append errors.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finished processing $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;--------------------------------------------------------&quot;&#160;&#160; <br />&#160;&#160;&#160; }       <br />#8-export all groups to csv file       <br />$ExportArray|export-csv export.csv       <br />}       <br />&quot;--------------------Finish: Prepare-DGToOffice365 Script ---------------------------------------------------&quot; | out-file -append errors.txt</p> </div>  <p>2- If you didn’t specify a group name when you run the script, this script will search for all distribution groups</p>  <p>3- After the script completes, the group will be moved to the NoDirSync OU.</p>  <p>4- The script will save any errors to errors.txt file</p>  <p><strong>Stage2: Validation:</strong></p>  <p>1- Run DirSync process</p>  <p>2- Check Office365 and make sure that the group is no more available in Office365</p>  <p><b>Stage3: Creation</b></p>  <p>1- From Azure PowerShell module, you can run the second script .\Create-DGToOffice365.ps1 –verbose</p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&lt;#&#160; <br />.SYNOPSIS&#160; <br />Use the Create-DGToOffice365.ps1 script to create the distribution groups in Office365 based on a csv file</p>    <p>     <br />.DESCRIPTION       <br />&#160;&#160;&#160; The ultimate objective is to delete all distribution groups from exchange on-premise and create them in the Office365 cloud.       <br />&#160;&#160;&#160; This sample script is the 1st script to create the distribution groups was previously removed from exchange on premise into Office365.       <br />&#160;&#160;&#160; </p>    <p>.NOTES&#160; <br />&#160;&#160;&#160; Author&#160;&#160;&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160; Ahmed Ashour - ahmed.ashour@hotmail.fr       <br />&#160;&#160;&#160; Creation Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; v1.0 4 Jan 2015       <br />&#160;&#160;&#160; Last Update&#160; :&#160;&#160;&#160;&#160;&#160; -----------------&#160; <br />#&#160; DISCLAIMER:       <br /># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.       <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR       <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL       <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,       <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE       <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION       <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>    <p>.PARAMETER Verbose      <br />Enabled verbose logging</p>    <p>.Example</p>    <p>.\Create-DGToOffice365.ps1      <br />This will create the distribution groups based on the csv file.</p>    <p>.\Create-DGToOffice365.ps1 -verbose      <br />This will create the distribution groupsbased on the csv file and enable verbose logging</p>    <p>.Inputs      <br />Script will require a csv file with all the attributes       <br />Name&#160;&#160;&#160; Members&#160;&#160;&#160; SamAccountName&#160;&#160;&#160; EmailAddresses&#160;&#160;&#160; ManagedBy&#160;&#160;&#160; AcceptMessagesOnlyFrom&#160;&#160;&#160; AcceptMessagesOnlyFromDLMembers&#160;&#160;&#160; AcceptMessagesOnlyFromSendersOrMembers&#160;&#160;&#160; BypassModerationFromSendersOrMembers&#160;&#160;&#160; ModeratedBy&#160;&#160;&#160; RejectMessagesFrom&#160;&#160;&#160; RejectMessagesFromDLMembers&#160;&#160;&#160; RejectMessagesFromSendersOrMembers&#160;&#160;&#160; GrantSendOnBehalfTo&#160;&#160;&#160; BypassNestedModerationEnabled&#160;&#160;&#160; MemberJoinRestriction&#160;&#160;&#160; MemberDepartRestriction&#160;&#160;&#160; ReportToManagerEnabled&#160;&#160;&#160; ReportToOriginatorEnabled&#160;&#160;&#160; SendOofMessageToOriginatorEnabled&#160;&#160;&#160; HiddenFromAddressListsEnabled&#160;&#160;&#160; ModerationEnabled&#160;&#160;&#160; RequireSenderAuthenticationEnabled&#160;&#160;&#160; SendModerationNotifications&#160;&#160;&#160; Alias&#160;&#160;&#160; CustomAttribute1&#160;&#160;&#160; CustomAttribute10&#160;&#160;&#160; CustomAttribute11&#160;&#160;&#160; CustomAttribute12&#160;&#160;&#160; CustomAttribute13&#160;&#160;&#160; CustomAttribute14&#160;&#160;&#160; CustomAttribute15&#160;&#160;&#160; CustomAttribute2&#160;&#160;&#160; CustomAttribute3&#160;&#160;&#160; CustomAttribute4&#160;&#160;&#160; CustomAttribute5&#160;&#160;&#160; CustomAttribute6&#160;&#160;&#160; CustomAttribute7&#160;&#160;&#160; CustomAttribute8&#160;&#160;&#160; CustomAttribute9&#160;&#160;&#160; DisplayName&#160;&#160;&#160; MaxSendSize&#160;&#160;&#160; MaxReceiveSize&#160;&#160;&#160; PrimarySmtpAddress&#160;&#160;&#160; SimpleDisplayName&#160;&#160;&#160; MailTip&#160;&#160;&#160; sendAs</p>    <p>.OUTPUTS      <br />Errors will be saved to errors.txt       <br />#&gt;&#160; </p>    <p>[CmdletBinding(SupportsShouldProcess=$true)]      <br />Param()</p>    <p>#Function to open the import csv file      <br />Function Get-FileName($initialDirectory)       <br />{&#160;&#160; <br />[System.Reflection.Assembly]::LoadWithPartialName(&quot;System.windows.forms&quot;) |       <br />Out-Null</p>    <p>$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog      <br />$OpenFileDialog.initialDirectory = $initialDirectory       <br />$OpenFileDialog.filter = &quot;All files (*.*)| *.*&quot;       <br />$OpenFileDialog.ShowDialog() | Out-Null       <br />return $OpenFileDialog.filename       <br />}       <br />$ImportFile=Get-FileName -initialDirectory &quot;c:\&quot;</p>    <p>#Function to connect to Office365      <br />Function New-O365ExchangeSession()       <br />{       <br />param([parameter(mandatory=$true)]$365master)</p>    <p>#close any old remote session      <br />Get-PSSession | Remove-PSSession -Confirm:$false</p>    <p>#start a new office 365 remote session      <br />$365session = New-PSSession -ConfigurationName &quot;Microsoft.Exchange&quot; -ConnectionUri '<a href="https://ps.outlook.com/powershell'">https://ps.outlook.com/powershell'</a> -Credential $365master -Authentication Basic -AllowRedirection       <br />$office365 = Import-PSSession $365session -AllowClobber</p>    <p>}      <br />$365master = get-credential ashour@myelephantdev.onmicrosoft.com       <br />New-O365ExchangeSession $365master</p>    <p>Function DoYExist()      <br />{       <br />param(       <br />[array]$RecordList,       <br />$Operation,       <br />$ParentGroup       <br />)       <br />&#160;&#160;&#160; $ValidValueToStr=@()       <br />&#160;&#160;&#160; Foreach($Record in $RecordList)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(Get-Recipient $Record | where{$_.RecipientType -eq &quot;UserMailbox&quot; -or $_.RecipientType -eq &quot;MailUniversalDistributionGroup&quot;})       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Found $($Record)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidValueToStr+=$Record&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;wrong user$($Record)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($ParentGroup)#$($Operation)#$($Record)#invalid User or Group&quot; | out-file -append errors.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />&#160;&#160;&#160; return ,$ValidValueToStr       <br />}</p>    <p>#Load CSV File      <br />$DateStamp = Get-Date -f &quot;dd-MM-yyyy&quot;       <br />$ListOfGroups=import-csv $ImportFile       <br />&quot;-------------------------Start: Create-DGToOffice365 Script $($DateStamp)--------------------------------&quot; | out-file -append errors.txt       <br />if($ListOfGroups)       <br />{       <br />&#160;&#160;&#160; ForEach($Group in $ListOfGroups)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Processing $($Group.name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; If(Get-DistributionGroup $Group.Name)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #1a-Group is available, exit       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;$($Group.Name) already exist&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Creating Group $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #1-Create the Group       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; New-DistributionGroup -Name $Group.Name -DisplayName $Group.displayName -PrimarySmtpAddress $Group.PrimarySmtpAddress -Alias $Group.alias       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#Creation#$($Error[0].Exception)&quot; | out-file -Append errors.txt}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finished processing $($Group.Name)&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;--------------------------------------------------------&quot;&#160;&#160; <br />&#160;&#160;&#160; }       <br />}       <br />else       <br />{       <br />&#160;&#160;&#160; &quot;No entries in the csv file&quot; | out-file -append errors.txt       <br />}       <br />&quot;--------------------Finish: Create-DGToOffice365 Script---------------------------------------------------&quot; | out-file -append errors.txt</p> </div>  <p>2- The script will ask you to provide the csv file will be used to create the distribution groups in office365</p>  <p><b>Stage4:Update</b></p>  <p>1- After all the distribution groups are created in Office365, it’s now possible to update all the properties that have group to group relations</p>  <p>2- From Azure PowerShell module, you can run the script .\Update-DGToOffice365.ps1 –verbose </p>  <div class="codeBlock" style="list-style-type: disc; overflow: auto; cursor: text; border-top: rgb(149,149,149) 1px solid; font-family: ; border-right: rgb(149,149,149) 1px solid; width: 587px; white-space: normal; word-spacing: 0px; border-bottom: rgb(149,149,149) 1px solid; text-transform: none; color: ; padding-bottom: 4px; padding-top: 4px; padding-left: 4px; margin: 10px 2px; border-left: rgb(149,149,149) 1px solid; letter-spacing: normal; line-height: 16px; padding-right: 4px; max-height: 250px; background-color: rgb(238,238,238); text-indent: 0px; -webkit-text-stroke-width: 0px" align="left">   <p>&lt;#&#160; <br />.SYNOPSIS&#160; <br />Use the Update-DGToOffice365.ps1 script to update the distribution groups attributes from a csv file</p>    <p>     <br />.DESCRIPTION       <br />&#160;&#160;&#160; The ultimate objective is to delete all distribution groups from exchange on-premise and create them in the Office365 cloud.       <br />&#160;&#160;&#160; This sample script is the 3rd script to update the distribution groups created on Office365 with the old information exported from exchange on-premise       <br />&#160;&#160;&#160; </p>    <p>.NOTES&#160; <br />&#160;&#160;&#160; Author&#160;&#160;&#160;&#160;&#160;&#160; :&#160;&#160;&#160;&#160;&#160; Ahmed Ashour - ahmed.ashour@hotmail.fr       <br />&#160;&#160;&#160; Creation Date:&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; v1.0 4 Jan 2015       <br />&#160;&#160;&#160; Last Update&#160; :&#160;&#160;&#160;&#160;&#160; ----------------- </p>    <p>#&#160; DISCLAIMER:      <br /># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.       <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR       <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL       <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,       <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE       <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION       <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.</p>    <p>.PARAMETER Verbose      <br />Enabled verbose logging</p>    <p>.Example</p>    <p>.\update-DGToOffice365.ps1      <br />This will set all the distribution groups properties based on the csv file.</p>    <p>.\update-DGToOffice365.ps1 -verbose      <br />This will set all the distribution groups properties based on the csv file and enable verbose logging</p>    <p>.Inputs      <br />Script will require a csv file with all the attributes       <br />Name&#160;&#160;&#160; Members&#160;&#160;&#160; SamAccountName&#160;&#160;&#160; EmailAddresses&#160;&#160;&#160; ManagedBy&#160;&#160;&#160; AcceptMessagesOnlyFrom&#160;&#160;&#160; AcceptMessagesOnlyFromDLMembers&#160;&#160;&#160; AcceptMessagesOnlyFromSendersOrMembers&#160;&#160;&#160; BypassModerationFromSendersOrMembers&#160;&#160;&#160; ModeratedBy&#160;&#160;&#160; RejectMessagesFrom&#160;&#160;&#160; RejectMessagesFromDLMembers&#160;&#160;&#160; RejectMessagesFromSendersOrMembers&#160;&#160;&#160; GrantSendOnBehalfTo&#160;&#160;&#160; BypassNestedModerationEnabled&#160;&#160;&#160; MemberJoinRestriction&#160;&#160;&#160; MemberDepartRestriction&#160;&#160;&#160; ReportToManagerEnabled&#160;&#160;&#160; ReportToOriginatorEnabled&#160;&#160;&#160; SendOofMessageToOriginatorEnabled&#160;&#160;&#160; HiddenFromAddressListsEnabled&#160;&#160;&#160; ModerationEnabled&#160;&#160;&#160; RequireSenderAuthenticationEnabled&#160;&#160;&#160; SendModerationNotifications&#160;&#160;&#160; Alias&#160;&#160;&#160; CustomAttribute1&#160;&#160;&#160; CustomAttribute10&#160;&#160;&#160; CustomAttribute11&#160;&#160;&#160; CustomAttribute12&#160;&#160;&#160; CustomAttribute13&#160;&#160;&#160; CustomAttribute14&#160;&#160;&#160; CustomAttribute15&#160;&#160;&#160; CustomAttribute2&#160;&#160;&#160; CustomAttribute3&#160;&#160;&#160; CustomAttribute4&#160;&#160;&#160; CustomAttribute5&#160;&#160;&#160; CustomAttribute6&#160;&#160;&#160; CustomAttribute7&#160;&#160;&#160; CustomAttribute8&#160;&#160;&#160; CustomAttribute9&#160;&#160;&#160; DisplayName&#160;&#160;&#160; MaxSendSize&#160;&#160;&#160; MaxReceiveSize&#160;&#160;&#160; PrimarySmtpAddress&#160;&#160;&#160; SimpleDisplayName&#160;&#160;&#160; MailTip&#160;&#160;&#160; sendAs</p>    <p>.OUTPUTS      <br />Errors will be saved to errors.txt       <br />#&gt;&#160; </p>    <p>[CmdletBinding(SupportsShouldProcess=$true)]      <br />Param()</p>    <p>#Function to open the import csv file      <br />Function Get-FileName($initialDirectory)       <br />{&#160;&#160; <br />[System.Reflection.Assembly]::LoadWithPartialName(&quot;System.windows.forms&quot;) |       <br />Out-Null</p>    <p>$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog      <br />$OpenFileDialog.initialDirectory = $initialDirectory       <br />$OpenFileDialog.filter = &quot;All files (*.*)| *.*&quot;       <br />$OpenFileDialog.ShowDialog() | Out-Null       <br />return $OpenFileDialog.filename       <br />}       <br />$ImportFile=Get-FileName -initialDirectory &quot;c:\&quot;</p>    <p>#Function to connect to Office365      <br />Function New-O365ExchangeSession()       <br />{       <br />param([parameter(mandatory=$true)]$365master)</p>    <p>&#160;&#160;&#160; #close any old remote session      <br />&#160;&#160;&#160; Get-PSSession | Remove-PSSession -Confirm:$false</p>    <p>&#160;&#160;&#160; #start a new office 365 remote session      <br />&#160;&#160;&#160; $365session = New-PSSession -ConfigurationName &quot;Microsoft.Exchange&quot; -ConnectionUri '<a href="https://ps.outlook.com/powershell'">https://ps.outlook.com/powershell'</a> -Credential $365master -Authentication Basic -AllowRedirection       <br />&#160;&#160;&#160; $office365 = Import-PSSession $365session -AllowClobber       <br />}       <br />$365master = get-credential #ashour@myelephantdev.onmicrosoft.com       <br />New-O365ExchangeSession $365master</p>    <p>#Function DoIExist      <br />Function DoYExist()       <br />{       <br />param(       <br />[array]$RecordList,       <br />$Operation,       <br />[String]$ParentGroup,       <br />[Parameter(Mandatory=$True)][string]$ImportFile       <br />)       <br />&#160;&#160;&#160; $ValidValueToStr=@()       <br />&#160;&#160;&#160; Foreach($Record in $RecordList)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(Get-Recipient $Record -erroraction &quot;silentlycontinue&quot;| where{$_.RecipientType -eq &quot;UserMailbox&quot; -or $_.RecipientType -eq &quot;MailUniversalDistributionGroup&quot;})       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Found $($Record)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidValueToStr+=$Record&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;wrong user$($Record)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($ParentGroup)#$($Operation)#$($Record)#invalid User or Group&quot; | out-file -append errors.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160; }       <br />&#160;&#160;&#160; return ,$ValidValueToStr       <br />}</p>    <p>#Load CSV File      <br />$ValueToArray=&quot;&quot;       <br />$DateStamp = Get-Date -f &quot;hh:mm-dd-MM-yyyy&quot;       <br />$ListOfGroups=import-csv $ImportFile       <br />&quot;-------------------------Start: Update-DGToOffice365 Script $($DateStamp)--------------------------------&quot; | out-file -append errors.txt       <br />if($ListOfGroups)       <br />{       <br />&#160;&#160;&#160; ForEach($Group in $ListOfGroups)       <br />&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Processing $($Group.name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; If(Get-DistributionGroup $Group.Name -erroraction silentlycontinue)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Found $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #1-Add X500 and smtp addresses       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Email addresses $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToArray=@($Group.EmailAddresses.split(&quot;;&quot;))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Set-DistributionGroup -Identity $Group.Name&#160; -EmailAddresses $ValueToArray       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#Email Addresses#$($Error[0].Exception)&quot; | out-file -Append errors.txt}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #2-Processing single value attribues       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Processing Single Value attributes&quot;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfSplat=@{}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #&quot;MaxSendSize&quot;,&quot;MaxReceiveSize&quot; are valid for onpremise but are not available for office365 set-distributingroup command       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Listofsingleprops=@(&quot;BypassNestedModerationEnabled&quot;,&quot;MemberJoinRestriction&quot;,&quot;MemberDepartRestriction&quot;,&quot;ReportToManagerEnabled&quot;,&quot;ReportToOriginatorEnabled&quot;,&quot;SendOofMessageToOriginatorEnabled&quot;,&quot;HiddenFromAddressListsEnabled&quot;,&quot;ModerationEnabled&quot;,&quot;RequireSenderAuthenticationEnabled&quot;,&quot;SendModerationNotifications&quot;,&quot;CustomAttribute1&quot;,&quot;CustomAttribute10&quot;,&quot;CustomAttribute11&quot;,&quot;CustomAttribute12&quot;,&quot;CustomAttribute13&quot;,&quot;CustomAttribute14&quot;,&quot;CustomAttribute15&quot;,&quot;CustomAttribute2&quot;,&quot;CustomAttribute3&quot;,&quot;CustomAttribute4&quot;,&quot;CustomAttribute5&quot;,&quot;CustomAttribute6&quot;,&quot;CustomAttribute7&quot;,&quot;CustomAttribute8&quot;,&quot;CustomAttribute9&quot;,&quot;DisplayName&quot;,&quot;Alias&quot;,&quot;PrimarySmtpAddress&quot;,&quot;SimpleDisplayName&quot;,&quot;MailTip&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Kei in $Listofsingleprops)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($Group.$($kei) -eq &quot;Null&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Skip $($kei)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Switch($Group.$($kei))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; True {$Kval=$True}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; False {$Kval=$False}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Default{$Kval=$Group.$($kei)}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfSplat.Add($kei,$Kval)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Set-distributiongroup -identity $Group.Name @ListOfSplat       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#SingleProps#$($Error[0].Exception)&quot; | out-file -Append errors.txt}</p>    <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #3- Processing MultiValue attributes &quot;GrantSendOnBehalfTo&quot;,&quot;ManagedBy&quot;,&quot;ModeratedBy&quot;,&quot;AcceptMessagesOnlyFromSendersOrMembers&quot;,&quot;BypassModerationFromSendersOrMembers&quot;,&quot;RejectMessagesFromSendersOrMembers&quot;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;Processing Multi Value attributes&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfMultiProps=@(&quot;GrantSendOnBehalfTo&quot;,&quot;ManagedBy&quot;,&quot;ModeratedBy&quot;,&quot;AcceptMessagesOnlyFromSendersOrMembers&quot;,&quot;BypassModerationFromSendersOrMembers&quot;,&quot;RejectMessagesFromSendersOrMembers&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Prop in $ListOfMultiProps)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;processing $($prop)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToArray=$Group.$($prop).split(&quot;;&quot;) | unique       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidValueToStr=(DoYExist $ValueToArray $prop $($Group.displayName))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if($ValidValueToStr)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $HashSplat=@{}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $HashSplat.Add($prop,$ValidValueToStr)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Set-DistributionGroup -Identity $($group.name) @HashSplat       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#$($prop)#$($Error[0].Exception)&quot; | out-file -Append errors.txt}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #4-Process MemberOf       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Processing MemberOf $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(!$Group.Members -eq &quot;Null&quot;)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValueToArray=$Group.members.split(&quot;;&quot;) | unique       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ValidValueToStr=(DoYExist $ValueToArray &quot;Members&quot; $($Group.displayName))       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($GroupMember in $ValidValueToStr)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;adding the member $($GroupMember)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Add-DistributionGroupMember -Identity $Group.Name -Member $GroupMember       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#Memberof#$($Error[0].Exception)&quot; | out-file -Append errors.txt}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #4-Process sendAs permission       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; write-verbose &quot;Processing the sendAs $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $ListOfTrustee=$Group.SendAs.split(&quot;;&quot;) | unique       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If($ListOfTrustee)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Foreach($Trustee in $ListOfTrustee)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #Cloud only Add-RecipientPermission $Group.Name -AccessRights SendAs -Trustee $Trustee -Confirm:$false       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; #On-Premise only Add-Adpermission $Group.Name -ExtendedRights Send-As -user $Trustee -Confirm:$false       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; $Error.Clear()       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;processing $($Trustee)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Add-RecipientPermission $Group.Name -AccessRights SendAs -Trustee $Trustee -Confirm:$false       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; If ($Error) {&quot;$($Group.displayName)#SendAs#$($Trustee)#$($Error[0].Exception)&quot; | out-file -Append errors.txt}       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; else       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Write-Verbose &quot;$($Group.Name) doesn't exist&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;$($Group.displayName)#Search for the Group#Doesn't Exist&quot; | out-file -Append errors.txt       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;Finished processing $($Group.Name)&quot;       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;--------------------------------------------------------&quot;&#160;&#160; <br />&#160;&#160;&#160; }       <br />}       <br />else       <br />{       <br />&#160;&#160;&#160; &quot;No entries in the csv file&quot; | out-file -append errors.txt       <br />}       <br />&quot;--------------------Finish: update-DGToOffice365 Script ---------------------------------------------------&quot; | out-file -append errors.txt</p> </div>  <p>3- The script will ask you to provide the csv file will be used to create the distribution group in office365</p>  <p>4- The script will save any errors to errors.txt file</p>  <p><b>Stage5:Cleanup</b></p>  <p>Once you feel everything is working fine you can connect to active directory and remove all groups in the NoDirSync OU.</p>  <p>Enjoy <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/3108.wlEmoticon-smile_632D185D.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/3108.wlEmoticon_2D00_smile_5F00_632D185D.png" /></p>  <p># THIS CODE IS SAMPLE CODE. THESE SAMPLES ARE PROVIDED &quot;AS IS&quot; WITHOUT WARRANTY OF ANY KIND.   <br /># MICROSOFT FURTHER DISCLAIMS ALL IMPLIED WARRANTIES INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR    <br /># A PARTICULAR PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF THE SAMPLES REMAINS WITH YOU. IN NO EVENT SHALL    <br /># MICROSOFT OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,    <br /># BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THE    <br /># SAMPLES, EVEN IF MICROSOFT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION    <br /># OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.    </p>]]></content:encoded>
    </item>
    <item>
      <title>Tip of The Day: SkyDrive SPF record</title>
      <link>https://docs.microsoft.com/archive/blogs/ashour/tip-of-the-day-skydrive-spf-record</link>
      <pubDate>Mon, 06 Oct 2014 08:56:19 GMT</pubDate>
      <dc:creator><![CDATA[A.Ashour]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/ashour/2014/10/06/tip-of-the-day-skydrive-spf-record/</guid>
      <description><![CDATA[&#160;  In a nutshell, if you run hybrid deployment and your MX records are still poining to on...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>In a nutshell, if you run hybrid deployment and your MX records are still poining to on premise exchange, you need to update your SPF record to include mail.sharepointonline.com</p>  <p>hmm, why do we need that? Let’s take a flash back.</p>  <p>We are running exchange 2013 on premise environment hybrid with Office 365.</p>  <p>We moved some users to the cloud service but we still keep our MX record pointing to our exchange environment.</p>  <p>Users started to work on OneDrive, formerly SkyDrive, and when they share any document/folder with their colleagues in the cloud/exchange on premise they immediately receive a non delivery report</p>  <table cellspacing="0" cellpadding="2" width="525" border="1"><tbody>     <tr>       <td valign="top" width="523">         <p>Unable to send Auto-Generate emails -&#160; Undeliverable</p>          <p>Delivery has failed to these recipients or groups:</p>          <p><a href="mailto:cloud-02@myeagle.dev">cloud-02@myeagle.dev</a></p>          <p>A communication failure occurred during the delivery of this message. Please try to resend the message later. If the problem continues, contact your helpdesk. </p>          <p>Diagnostic information for administrators:</p>          <p>Generating server: AM1YL1SMTP003.YLO001.MSOPRD.MSFT.NET</p>          <p><a href="mailto:cloud-01@myeagle,dev">cloud-01@myeagle,dev</a></p>          <p>Remote Server returned '&lt; #5.5.0 smtp;553 Sender Policy Framework (SPF) fail&gt;'</p>          <p><a href="mailto:cloud-02@myeagle.dev.com">cloud-02@myeagle.dev</a></p>          <p>Remote Server returned '&lt; <font color="#ff0000">#5.5.0 smtp;553 Sender Policy Framework (SPF) fail</font>&gt;'</p>          <p>Original message headers:</p>          <p>Received: from CFE4311788-024 ([157.55.231.54]) by</p>          <p><font color="#ff0000">AM1YL1SMTP003.YLO001.MSOPRD.MSFT.NET</font> with Microsoft SMTPSVC(7.5.7601.17514);</p>       </td>     </tr>   </tbody></table>  <p>Looking into the MX record, our example domain is pointing to other mail server rather than Office365</p>  <table cellspacing="0" cellpadding="2" width="400" border="1"><tbody>     <tr>       <td valign="top" width="400">         <p>&gt; set q=mx            <br />&gt; myeagle.dev</p>          <p>Non-authoritative answer:            <br />myeagle.dev&#160;&#160;&#160;&#160;&#160;&#160; MX preference = 10, mail exchanger = cluster8a.eu.messagelabs.com             <br />myeagle.dev&#160;&#160;&#160;&#160;&#160; MX preference = 5, mail exchanger = cluster8.eu.messagelabs.com</p>          <p>cluster8a.eu.messagelabs.com&#160;&#160;&#160; internet address = 216.82.251.230            <br />cluster8a.eu.messagelabs.com&#160;&#160;&#160; internet address = 85.158.139.103</p>       </td>     </tr>   </tbody></table>  <p>SkyDrive has a built-in SMTP server which helps to send outbound messages (e.g. system notification email, invitation email of shared folder or site). </p>  <p>When a message is sent from SkyDrive, the next hop for routing is determined by MX record lookup. </p>  <p>In current scenario, the MX record of myeagle.dev is pointing to mail gateway of messagelabs.com. That is why the message will be sent to messagelabs.com and sent back to Office 365 if the user in the cloud</p>  <p>MessageLabs check the SPF record to protect the environment from spoofing, so the email is rejected because SPF is setup for hard fail and the SPF record doesn’t include the SkyDrive IPs.</p>  <table cellspacing="0" cellpadding="2" width="522" border="1"><tbody>     <tr>       <td valign="top" width="520">         <p>&gt; set q=txt            <br />&gt; myeagle.dev</p>          <p>Non-authoritative answer:            <br />myeagle.dev&#160;&#160;&#160;&#160;&#160;&#160; text =</p>          <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;v=spf1 a mx include:spf.protection.outlook.com -all&quot; </p>       </td>     </tr>   </tbody></table>  <p>Digging more in the message header we could see that SkyDrive is sending from am1.mail.sharepointonline.com and that’s the Joshua puzzle we are missing in our SPF.</p>  <table class="MsoNormalTable" style="list-style-type: disc; border-collapse: collapse; mso-yfti-tbllook: 1184; mso-padding-alt: 0in 0in 0in 0in" cellspacing="0" cellpadding="0" width="523" border="1"><thead>     <tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes">       <td style="border-top: #a8b2b2 1pt solid; border-right: #a8b2b2 1pt solid; background: #0072c6; border-bottom: #a8b2b2 1pt solid; padding-bottom: 6pt; padding-top: 6pt; padding-left: 6pt; border-left: medium none; padding-right: 6pt" valign="top" width="337">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt" align="center"><span style="font-family: ; color: "><font style="font-size: 9pt" color="#ffffff">Submitting host↓↑</font></span></p>       </td>        <td style="border-top: #a8b2b2 1pt solid; border-right: #a8b2b2 1pt solid; background: #0072c6; border-bottom: #a8b2b2 1pt solid; padding-bottom: 6pt; padding-top: 6pt; padding-left: 6pt; border-left: medium none; padding-right: 6pt" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt" align="center"><span style="font-family: ; color: "><font style="font-size: 9pt" color="#ffffff">Receiving host↓↑</font></span></p>       </td>     </tr>   </thead><tbody>     <tr style="mso-yfti-irow: 1">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="330">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">am1yl1smtp003.ylo001.msoprd.msft.net (<span style="background-image: none; background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; mso-highlight: yellow"><font style="background-color: #ffff00">am1.mail.sharepointonline.com</font></span> [157.55.231.39])</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">ZZSDC2PROOF-A1.kering.net</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 2">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="324">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">pps.filterd (ZZSDC2PROOF-A1.kering.net [127.0.0.1])</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">ZZSDC2PROOF-A1.kering.net (8.14.5/8.14.5)</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 3">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="322">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">smtp2.pprgroup.net (172.25.66.34)</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">MyeagleE15.myeagle.dev</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 4">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="321">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">MyeagleE15.myeagle.dev</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">fnacsmtp2.kering.net (172.26.196.72)</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 5">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="321">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">fnacsmpt1.kering.net (193.104.231.160)</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AM1FFO11FD048.mail.protection.outlook.com (10.174.65.211)</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 6">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="321">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AM1FFO11FD048.protection.gbl (2a01:111:f400:7e00::185)</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AM3PR06CA040.outlook.office365.com (2a01:111:e400:882b::30)</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 7">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="321">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AM3PR06CA040.eurprd06.prod.outlook.com (10.141.192.158)</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AMSPR06MB054.eurprd06.prod.outlook.com (10.242.82.20)</font></span></p>       </td>     </tr>      <tr style="mso-yfti-irow: 8; mso-yfti-lastrow: yes">       <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="321">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">AMSPR06MB054.eurprd06.prod.outlook.com (10.242.82.20)</font></span></p>       </td>        <td style="border-top: medium none; border-right: #a8b2b2 1pt solid; background: #cde6f7; border-bottom: #a8b2b2 1pt solid; padding-bottom: 12pt; padding-top: 4.8pt; padding-left: 1.5pt; border-left: medium none; padding-right: 0.2in" valign="top" width="184">         <p class="MsoNormal" style="margin: 0in 0in 0pt; line-height: 14.4pt"><span style="font-family: ; color: "><font style="font-size: 9pt">DB4PR06MB061.eurprd06.prod.outlook.com (10.242.154.19)</font></span></p>       </td>     </tr>   </tbody></table>  <p>Finally changing SPF record solve the issue</p>  <table cellspacing="0" cellpadding="2" width="522" border="1"><tbody>     <tr>       <td valign="top" width="520">         <p>&gt; set q=txt            <br />&gt; myeagle.dev</p>          <p>Non-authoritative answer:            <br />myeagle.dev&#160;&#160;&#160;&#160;&#160;&#160; text =</p>          <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;v=spf1 a mx include:spf.protection.outlook.com <font color="#0000ff">include:mail.sharepointonline.com</font> -all&quot; </p>       </td>     </tr>   </tbody></table>  <p>Case Solved, Enjoy <img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="Smile" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/56/91/metablogapi/7356.wlEmoticon-smile_561509A6.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-56-91-metablogapi/7356.wlEmoticon_2D00_smile_5F00_561509A6.png" /></p>]]></content:encoded>
    </item>
  </channel>
</rss>