<?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>Microsoft Exchange pour Tous V2 - Microsoft Exchange made simple</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/samdrey/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/samdrey/feed.xml</link>
    <description>Nouveautés, principes, évolution, trucs et astuces - News, principles, evolution, tips and tricks</description>
    <lastBuildDate>Tue, 12 Feb 2019 02:19:31 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How-To – Find how many connections Outlook makes to your Exchange infrastructure using Netstat.exe</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/how-to-find-how-many-connections-outlook-makes-to-your-exchange-infrastructure-using-netstat-exe</link>
      <pubDate>Mon, 11 Feb 2019 13:05:13 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5485</guid>
      <description><![CDATA[In this quick procedure we leverage TaskList.exe command (default Windows command line utility) to...]]></description>
      <content:encoded><![CDATA[In this quick procedure we leverage <strong>TaskList.exe</strong> command (default Windows command line utility) to get a specific process name and ID, and the <strong>Netstat.exe</strong> command (also a default Windows command line utility) to quickly find the opened connections from a specific application.

&nbsp;

<strong><em>Note</em></strong><em>: you can use other tools to get these, like the Windows Task Manager for example to find the process names and IDs, and/or the excellent <span><a target="_blank" href="https://docs.microsoft.com/en-us/sysinternals/downloads/tcpview" rel="noopener">TCPView from sysinternals</a></span> to graphically see the opened connections along with process names… or you can use any network analyzer tool (like Microsoft Message Analyzer, Network Monitor, Wireshark, …) or even the Windows Resource Monitor (Resmon.exe)  if you prefer.</em>

<strong> </strong>

When you launch an application like Outlook, it usually opens a process that has a specific ID. We are going to get the ID for the Outlook application, which associated process and then run Netstat to find out how many lines, in other words how many network connections and on which port do we have opened for Outlook.

<strong> </strong>
<ul>
 	<li>
<h1><strong>Step 1: Get your Outlook PID using Tasklist</strong></h1>
</li>
</ul>
&nbsp;

Run the below command:
<pre>Tasklist | find /I “outlook.exe”</pre>
This command is leveraging MS-DOS TaskList.exe command, and we use the “Find” command after a pipe to just output the line of the whole output that include the “outlook.exe” process.

The output will look like the below:

<a href="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-1.png"><img src="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-1.png" alt="" width="624" height="37" class="alignnone size-full wp-image-5495" /></a>

<span>Fig. 1 - Outlook PID = 4028</span>

<span> </span>
<ul>
 	<li>
<h1><strong>Step 2 : Get the opened connections by this PID using Netstat:</strong></h1>
</li>
</ul>
&nbsp;

Run the below command:
<pre>netstat-ano -p TCP | find /I “PID_Found_Above”</pre>
This command leverages Netstat with the -a -n -o options combined into one -ano parameter, and focussing on the TCP protocol. Then we use the “Find” command after a pipe to just output the line that include our process ID that we found on Step 1.

<a href="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-2.png"><img src="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-2.png" alt="" width="620" height="54" class="alignnone size-full wp-image-5505" /></a>

<span>Fig. 2 – 2 entries, one for Mailbox connection, one for Directory connection</span>

<span> </span>

<span>Here I see 2 entries:</span>

<span> </span>
<pre><span>TCP        192.168.2.56:50701               192.168.2.50:443            ESTABLISHED               4028</span>
<span>TCP        192.168.2.56:50702               192.168.2.50:443            ESTABLISHED               4028</span></pre>
<span> </span>

<span>One is for Mailbox connection (download e-mail body and attachments, mark e-mail as read, move and/or delete e-mails, etc...), and the other one is for Directory connection (for address book resolution in Outlook, address book searches, etc…).</span>

<span> </span>
<h1><strong><span>Conclusion</span></strong></h1>
<span>When you see 2 entries like the above example that I paste below again:</span>
<pre>TCP        192.168.2.56:50701               192.168.2.50:443            ESTABLISHED               4028
TCP        192.168.2.56:50702               192.168.2.50:443            ESTABLISHED               4028</pre>
This means I have 2 network connections that Outlook is making to my Exchange server. Note that this is the case for MAPI over HTTP, <strong><u>AND</u></strong> when you don’t have any additional mailboxes (shared mailboxes or a mailbox where you have full mailbox access and brought to your profile using auto-mapped mailboxes).

<span>If you are using Outlook Anywhere aka RPC over HTTP (which is deprecated in Office 365’s Exchange Online), we will have an additional connection, as RPC over HTTP needs 2 connections as opposed to MAPI over HTTP: one RPC over HTTP connection for e-mail sending (RPC-OUT : uploading e-mail data from Outlook to Exchange), and one RPC over HTTP connection for e-mail receiving (RPC-IN : downloading e-mail data from Exchange to Outlook) – that way with the Exchange Directory connection, we will have at least 3 connections for an Outlook with a profile that just has one mailbox configured in Online mode).</span>

<span> </span><span> </span>

<span>On Outlook (in Online mode) Connection Status you will find 3 entries:</span>
<ul>
 	<li><strong>Exchange Directory which session type is Foreground</strong></li>
 	<li><strong>Exchange Mail which session type is Foreground as well</strong></li>
 	<li>And another Exchange Directory which session type is “Background”</li>
</ul>
<span> <a href="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-3.png"><img src="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-3.png" alt="" width="624" height="88" class="alignnone size-full wp-image-5515" /></a></span>

<span>Fig.3 – Outlook Connection Status view</span>

<span> </span><span> </span>

<span>The Exchange Directory “Background” is essentially there for the cached entries, but does not account for a network connection. As long as Netstat shows only 2 entries, I guess we can tell the network guys that Outlook / Exchange in MAPI over HTTP mode, without other Public Folder and without additional groups and shared mailboxes, only needs 2 network connections opened between Outlook and Exchange…</span>

<span> </span><strong><span>Note</span></strong><span>: the TCPView tool mentioned above enabled you to get the application name and its opened Network connections a bit faster, here’s an example here:</span>

<a href="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-4.png"><img src="https://msdnshared.blob.core.windows.net/media/2019/02/Fig-4.png" alt="" width="624" height="143" class="alignnone size-full wp-image-5525" /></a>

<span>Fig. 4 - TCPView graphical user friendly interface to achieve the same as the above 2 steps, in one tool</span>

<span> </span>
<h1><span>Resources</span></h1>
<span> </span><span>Remove Automapping for a shared mailbox in Office 365</span>

<span><a target="_blank" href="https://support.microsoft.com/en-us/help/2646504/how-to-remove-automapping-for-a-shared-mailbox-in-office-365" rel="noopener">https://support.microsoft.com/en-us/help/2646504/how-to-remove-automapping-for-a-shared-mailbox-in-office-365</a></span>

Microsoft Message Analyzer:

<span><a target="_blank" href="https://www.microsoft.com/en-us/download/details.aspx?id=44226" rel="noopener">https://www.microsoft.com/en-us/download/details.aspx?id=44226</a></span>

<span>Network Monitor v3.4 (deprecated but still functional)</span>

<span><a target="_blank" href="https://www.microsoft.com/en-us/download/4865" rel="noopener">https://www.microsoft.com/en-us/download/4865</a></span>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Exchange 2013/2016/2019 &amp; ExO - a sample Get-Mailbox GUI</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/exchange-get-mailboxes-gui</link>
      <pubDate>Mon, 19 Nov 2018 00:05:34 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5455</guid>
      <description><![CDATA[Here is a GUI to get mailboxes information in an Exchange 2010, 2013, 2016, 2019 and/or Exchange...]]></description>
      <content:encoded><![CDATA[Here is a GUI to get mailboxes information in an Exchange 2010, 2013, 2016, 2019 and/or Exchange Online (O365) environments.
I initially created this GUI just to illustrate how we can use Windows Presentation Foundation (WPF) forms to ease up the execution of PowerShell commands.
<a href="#DownloadLink">Download link is at the very end of this article.</a>
<h1>Principle</h1>

<hr />

For this GUI, I designed the interface using Windows Presentation Foundation, which is the next generation of Windows Forms, and which enables anyone to design Windows interfaces for underlying programs, to help users to get the most from computer programs.

Here's the principle used to create this Powershell application using WPF:
<ul>
 	<li>First, I designed the Windows Presentation Foundation forms using Visual Studio 2017 Community Edition (which is free), and pasted the generated XAML code from Visual Studio 2007 into a PowerShell script - in this script I pasted directly the XAML code into a PowerShell "here-string", but you can load the XAML code from a separate file using Get-Content for example, that way if you want to change your Windows WPF form design, you just have to modify or paste the new code from Visual Studio directly into that separate file and leave your .ps1 script alone.</li>
 	<li>then with a PowerShell code snippet I parsed the XAML code to get the form objects that PowerShell understands - buttons, check boxes, datagrids, labels, text blocks used as inputs as well as outputs sometimes (to put the PowerShell commands corresponding to the users input for example), and the form object itself, which is the container of all the other objects (buttons, checkboxes, etc...)</li>
 	<li>and finally I wrote the functions behind the form that I want to run when the form loads, when we click the buttons, when we check or uncheck the checkboxes, when we change the text in text boxes, or when we select items from datagrids =&gt; for code to execute when the user interacts with Windows WPF forms, we must use the WPF form object's "events" (add_click, add_textChanged, add_loaded, add_closing, etc...) =&gt; you can retrieve Windows WPF form objects on the MSDN, or simply on Visual Studio 2017 when you design your form (switch from object properties to the object events to view all available events for a selected object)</li>
</ul>
&nbsp;
<ul></ul>
I tried to make a synoptic view of the process in the below schema with small sample screenshots of my Visual Studio 2007 / Vistual Studio Code parts - you'll find the WPF - to - PowerShell code snippet sample I'm referring to in the below schema in <a target="_blank" href="https://github.com/SammyKrosoft/Code-Snippet-WPF-and-PowerShell" rel="noopener">this GitHub repository</a>...

<img alt="WPF from Visual Studio to PowerShell" src="https://github.com/SammyKrosoft/Code-Snippet-WPF-and-PowerShell/raw/master/DocResources/How-o-CreatePowerShellWPFApp.jpg" width="1541" height="1940" class="alignnone" />
<h1>Important notes</h1>

<hr />

This PowerShell app requires PowerShell V3, and also requires to be run from a PowerShell console with Exchange tools loaded, which can be an Exchange Management Shell window or a PowerShell window from where you imported an Exchange session, see my TechNet blog post for a summary on how to do this (<em>right-click =&gt; Open in a new tab otherwise below sites will load instead of this page</em>):
<blockquote>
<ul>
 	<li><a href="https://blogs.technet.microsoft.com/samdrey/2018/04/06/how-to-load-remote-powershell-session-on-exchange-2010-2013-2016-exchange-online-o365-2/">How-to – Load Remote Exchange PowerShell Session on Exchange 2010, 2013, 2016, Exchange Online (O365) – which ports do you need</a></li>
 	<li>
<p id="connect-to-exchange-online-powershell"><a target="_blank" href="https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/connect-to-exchange-online-powershell?view=exchange-ps" rel="noopener">Connect to Exchange Online PowerShell</a></p>

<ul>
 	<li>
<p id="connect-to-exchange-online-powershell"><em>Note: If you want to use multi-factor authentication (MFA) to connect to Exchange Online PowerShell, you need to download and use the Exchange Online Remote PowerShell Module. For more information, see <a href="https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powershell/mfa-connect-to-exchange-online-powershell?view=exchange-ps">Connect to Exchange Online PowerShell using multi-factor authentication</a></em></p>
</li>
</ul>
</li>
 	<li><a href="https://blogs.technet.microsoft.com/samdrey/2017/12/17/how-to-load-exchange-management-shell-into-powershell-ise-2/">How To–Load Exchange Management Shell into PowerShell ISE</a></li>
</ul>
</blockquote>
<h1>Screenshots - because a picture is worth 1000 words...</h1>

<hr />

<h5>First window when launching the tool</h5>
<img alt="screenshot1" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image0.jpg" />
<h5>After a sample Get-Mailbox which name includes "user" string</h5>
<img alt="screenshot2" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image1.jpg" width="1013" height="529" class="alignnone" />

Note that for cloud mailbox, the "Location" column will tell you that the mailbox is hosted in the cloud:

<img alt="screenshot2.1" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image1-cloud_location.jpg" width="1017" height="531" class="alignnone" />
<h5>If you select "Unlimited" under the Resultsize (max number of mailboxes to search), or a number that is greater than 1000, you get a warning asking you if you want to continue</h5>
<img alt="screenshot3" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-Question-LotsOfItems.jpg" width="466" height="165" class="alignnone" /> <img alt="screenshot3.1" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-Question-LotsOfItems2.jpg" width="475" height="165" class="alignnone" />
<h5>Selecting mailboxes in the grid, notice the "Action on selected" button that becomes active</h5>
<img alt="screenshot4" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-SelectForAction.jpg" width="1013" height="529" class="alignnone" />
<h5>Action : After selecting some mailboxes in the grid, calling the "List Mailbox Features" action in the drop-down list</h5>
<img alt="screenshot5" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-Action-ListMbxFeatures.jpg" width="858" height="443" class="alignnone" />
<h5>Action: Anoter action possible, calling the Single Item Recovery and mailbox dumpster limits for the selected mailboxes</h5>
<img alt="screenshot6" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-Action-SingleItemRecoveryStatus.jpg" width="858" height="443" class="alignnone" />
<h5>Action: List mailbox quotas, including database quota for each mailbox</h5>
<em>Note that mailbox quotas list include the Database info quota - that is useful when mailboxes are configure to use Mailbox Database Quotas</em> <img alt="screenshot7" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-Action-ListMailboxQuotas.jpg" width="858" height="443" class="alignnone" />
<h5>On most actions, you can copy the list in Windows clipboard (will be CSV Formatted) for further analyis, reporting or documentation about your mailboxes</h5>
<img alt="screenshot8" src="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI/raw/master/DocResources/image-copyToClipBoard.jpg" width="301" height="165" class="alignnone" />
<h1 id="DownloadLink">More to come...</h1>

<hr />

<span style="font-size: x-large"><a target="_blank" href="https://gallery.technet.microsoft.com/Exchange-201320162019ExO365-e0a75aa4" rel="noopener">Download link</a></span>

You can also retrieve this project on <a target="_blank" href="https://github.com/SammyKrosoft/Exchange-Get-Mailboxes-GUI" rel="noopener">this page of my GitHub site</a>...]]></content:encoded>
    </item>
    <item>
      <title>Exchange Server 2013/2016/2019 Components Checker</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/exchange-server-components-checker</link>
      <pubDate>Mon, 29 Oct 2018 22:15:37 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5425</guid>
      <description><![CDATA[Here’s the latest addition in Exchange 2013/2016/2019 server quick tools. Sometimes, for maintenance...]]></description>
      <content:encoded><![CDATA[Here’s the latest addition in Exchange 2013/2016/2019 server quick tools. Sometimes, for maintenance or issues detected by Exchange Managed Availability, some components like Client Access, Autodiscover, Mail flow, etc... can be down on Exchange servers, which "exclude" these servers from the pool of Exchange servers. Here's a tool that helps you to check the state of every Exchange Server’s components and optionally start these if they are inactive (<a href="#download"><strong>tool download link at the end of this article</strong></a>)

NOTE: this tool needs to be run from an Exchange Management Shell, or from a PowerShell host where you imported an Exchange PowerShell session

These “Server Components” were introduced back in Exchange 2013, and are part of the Exchange Managed Availability features, and are there to ease server maintenance: inactive components are not targeted by the Client Access Services so that you can perform maintenance without having to affect the other Exchange services.
<ul>
 	<li>Choose your server version, Exchange 2013 or Exchange 2016 (Exchange 2019 coming soon), to check the components from</li>
 	<li><strong>[ ] CheckOnly</strong> checkbox will just check and show each component from each of your organization’s servers: if checked, the tool will not attempt to start the inactive components</li>
 	<li><strong>[ ] HybridServer</strong> checkbox will check two additional components that are used on Hybrid Exchange – O365 scenarios</li>
 	<li><strong>[ ] Show Inactive Only</strong> : this checkbox will filter out all the Active components, so that you can check right away which servers and which components have Inactive services. You can check or uncheck it anytime, before or after the Server Components collection</li>
 	<li>Once you are happy with the chosen options, click the <strong>[Run]</strong> button to start gathering the information (at the bottom is the status bar along with a status label)</li>
</ul>
<a href="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/blob/master/DocResources/image0.jpg"><img alt="screenshot1" src="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/raw/master/DocResources/image0.jpg" /></a>

NOTE: once the components are gathered and show up, you can select all (click on one of the result cell, then CTRL+ a followed by CTRL + v) and paste it in a report, in Excel:

<a href="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/blob/master/DocResources/image1.jpg"><img alt="screenshot2" src="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/raw/master/DocResources/image1.jpg" /></a>

And finally, you're able to start the Exchange Server Components with the requester of your choice (Maintenance, SideLine, Functional, Deployment,...) - just uncheck the <strong>[ ] CheckOnly</strong> check box, choose your requester, and click <strong>[Run]</strong>

<a href="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/blob/master/DocResources/image2.jpg"><img alt="screenshot3" src="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck/raw/master/DocResources/image2.jpg" /></a>

More information on these Exchange Server Components: <a href="https://blogs.technet.microsoft.com/exchange/2013/09/26/server-component-states-in-exchange-2013/" id="download">blogs.technet.microsoft.com/exchange/2013/09/26/server-component-states-in-exchange-2013</a>
&nbsp;

<a target="_blank" href="https://gallery.technet.microsoft.com/Exchange-Server-Component-855076f7" rel="noopener"><strong>Download this tool here.</strong></a>

&nbsp;

You can also retrieve this project on <a target="_blank" href="https://github.com/SammyKrosoft/Start-E2016ServerComponentsCheck" rel="noopener">this page of my GitHub site</a>...]]></content:encoded>
    </item>
    <item>
      <title>Dynamic Distribution Group creation tool (PowerShell command generator to create Distribution Groups)</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/dynamic-distribution-group-creation-tool-powershell-command-generator-to-create-distribution-groups</link>
      <pubDate>Fri, 08 Jun 2018 19:59:50 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5395</guid>
      <description><![CDATA[I. Introduction
See the Download section below for the link to download the tool.

In Exchange...]]></description>
      <content:encoded><![CDATA[<h1>I. Introduction</h1>
See the <a href="#Download">Download section below for the link to download the tool.</a>

In Exchange 2010/2013/2016 and Exchange Online (the messaging component of Office 365), we can create Dynamic Distribution Groups in two ways :
<ol>
 	<li>Using the Exchange Administration Console (HTML based)</li>
 	<li>Using the Exchange Management Shell (Command line based)</li>
</ol>
More information about the ways to create and manage Dynamic Distribution Groups on <a target="_blank" href="https://technet.microsoft.com/en-us/library/bb123722(v=exchg.150).aspx" rel="noopener">this link</a>…

The Dynamic Distribution Groups are a type of group that base their memberships on a query on other mail-enabled objects such as User Mailboxes, Room Mailboxes, or any object stamped with an e-mail address and that Exchange Server can read.
<blockquote>NOTE: When we use PowerShell to create a Dynamic Distribution Group, if we don’t specify the Scope of the query of a Dynamic Distribution Group, by default the scope will be the location where the Dynamic Distribution Group is created =&gt; and this is often something that takes hours until we found the cause of “non-working” Dynamic Distribution Groups, because everything else look very normal about these.</blockquote>
The tool I am giving here is meant to generate the PowerShell (Exchange Management Shell actually because you need the Exchange Tools to make it work) command line to create a Dynamic Distribution Group, without forgetting to specify the “scope” of the Dynamic Distribution Group filter.

Also, the other command line generated is meant to modify the scope and the filter of an exising Dynamic Distribution Group.

This is an Excel based PowerShell command generator, next challenge is to do the same but with WPF ! That will be for another blog post !
<h1>II. Tool description</h1>
<h2>a. General overview</h2>
<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0027.png"><img width="854" height="648" title="clip_image002" alt="clip_image002" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image002_thumb6.png" border="0" /></a>

The tool is composed of 2 main parts:
<ol>
 	<li>The <b>input part</b>, where we define the Dynamic Distribution Group <b>scope</b>, its <b>location</b> (an Organizational Unit), its <b>name</b>, optionally its <b>Alias</b> (that is what is used to generate the Dynamic DG e-mail address) – if you don’t specify it, Exchange will automatically convert the name into an alias, replacing all spaces and special characters with an hyphen or a dash (“-“).</li>
 	<li>The <b>PowerShell command</b> part, that you will copy and paste on an Exchange PowerShell window to create or modify your Dynamic Distribution Group. There are 2 command lines in that part :</li>
</ol>
<p style="padding-left: 60px">a. <pre>New-DynamicDistributionGroup</pre>-&gt; that is to create a new Dynamic Distribution Group with the parameters you chose on the part #1 – Input part.
b. <pre>Get-DynamicDistributionGroup</pre>-&gt; that is to <b><u>modify</u></b> an existing Dynamic Distribution Group with the <b><u>scope</u></b> and <b><u>filter</u></b> parameters you chose on the part #2 – Input part.</p>
<h2>b. Input details</h2>
See the below schema for the explanation of each input part.

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0045.png"><img width="854" height="629" title="clip_image004" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image004_thumb5.png" border="0" /></a>
<h2>c. Command part details</h2>
See the below schema for the explanation of the two PowerShell command lines.

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0063.png"><img width="854" height="538" title="clip_image006" alt="clip_image006" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image006_thumb3.png" border="0" /></a>
<h1>III- Using these to create a new Dynamic DG or modify an existing Dynamic DG</h1>
<i>NOTE: for this last part, you need the following skills : ability to copy and paste things</i>

Once you have your command line ready, that are generated by the tool based on the input parameters you chose, just copy one of the command lines, and paste it on a script, or directly on the Exchange Management Shell.

Example, I want to create a new Dynamic Distribution Group with the sample options of the screenshots above :

<strong>- Step #1 : Select the blue box and hit CTRL + C</strong>

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0082.png"><img width="854" height="195" title="clip_image008" alt="clip_image008" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image008_thumb2.png" border="0" /></a>

<strong>- Step #2 : Paste the command</strong>

You can choose either to paste the command on a <strong>Notepad</strong> to save it later as a .PS1 script:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0102.png"><img width="854" height="516" title="clip_image010" alt="clip_image010" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image010_thumb2.png" border="0" /></a>

Or you can paste it on a <strong>PowerShell ISE</strong> window on your remote connected server:

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image0122.png"><img width="854" height="478" title="clip_image012" alt="clip_image012" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image012_thumb2.png" border="0" /></a>

Or you can directly paste it on an <strong>Exchange Management Shell</strong> window (<b>WARNING: this will execute your command as well</b>):

<a href="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image014.png"><img width="854" height="86" title="clip_image014" alt="clip_image014" src="https://msdnshared.blob.core.windows.net/media/2018/06/clip_image014_thumb.png" border="0" /></a>

And that applies for both of the blue boxes containing the <strong>New-DynamicDistributionGroup / Set-DynamicDistributionGroup</strong> commands.

&nbsp;
<a id="Download"><h1>IV- Download link</h1></a>

Of course you can use it to create a base command line, and then add all the options you want to customize your Dynamic Distribution Groups, the tool just generates the basics of a Dynamic Distribution Group creation and only modifies the scope and filter … for example we don’t set any delivery restrictions, owners, etc…, just the basics.

You can <a target="_blank" href="https://gallery.technet.microsoft.com/Exchange-Dynamic-58af31b3" rel="noopener">DOWNLOAD this Excel tool here</a>.

Have a good one !
Cheers
Sam]]></content:encoded>
    </item>
    <item>
      <title>PowerShell command line generator for Exchange (2010,2013, 2016) Recovery Database creation and make it use existing database and log files</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/powershell-command-line-generator-for-exchange-20102013-2016-recovery-database-creation-and-make-it-use-existing-database-and-log-files</link>
      <pubDate>Tue, 05 Jun 2018 10:11:23 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5245</guid>
      <description><![CDATA[Description
Download link  at the very end of this article...

This program is a Graphical User...]]></description>
      <content:encoded><![CDATA[<h1><span>Description</span></h1>
Download link <a href="#download"> at the very end of this article</a>...

This program is a Graphical User Interface that will help you generating Exchange Management Shell command lines to:
<ol>
 	<li>Create a Recovery Database using temporary path for the database and its corresponding LOG files set</li>
 	<li>Point that newly created Recovery Database to an existing database file and its corresponding LOG files set</li>
 	<li>Display the newly created Recovery Database and its paths just modified</li>
 	<li>Mount the Recovery Database using the existing database file and corresponding LOG files set</li>
 	<li>(or 4bis) - Displaying the status and file paths of that database again (just to confirm)</li>
</ol>
<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/ExchangeRecoveryDatabasePowerShellCmdGenerator.png"><img alt="Fig.1" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/ExchangeRecoveryDatabasePowerShellCmdGenerator.png" /></a>
<h1><span>Launching it</span></h1>
Just type <code>.\Launch-RecoveryDatabaseCreateGUI.ps1</code> or "Run with Powershell" from Windows Explorer:

<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/RunWithPowerShell.png"><img alt="Fig.2" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/RunWithPowerShell.png" /></a>

Once you have the desired values for your Server name, your EDB file and LOG paths, etc..., Clicking on the [Copy to Clipboard] button will copy the command list to the Clipboard.

=&gt; that way, you will be able to paste your commands in a PowerShell script, or in a NOTEPAD, or directly in an Exchange Management Shell for immediate execution !

<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/CopiedToClipboard.png"><img width="546" height="214" alt="Fig.3" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/CopiedToClipboard.png" class="" /></a>
<blockquote>Note: In order to see the "Run with Powershell" context menu on Windows Explorer, you need to set "Notepad" as the default "open with" program for .PS1 files -&gt; see the "Miscellaneous" section below if you don't have your "Run with PowerShell" menu and if you with to get it back.</blockquote>
<blockquote>Note2: if you reset the ".PS1" file association with NOTEPAD, you'll lose any previous association you made with ".PS1" files...</blockquote>
<h1><span>Miscellaneous : How to retrieve your "Run with Powershell" menu from Windows Explorer</span></h1>
If you don't find your "Run with PowerShell" menu anymore when right-clicking a PS1 file, you just have to reset the default program to open .PS1 to be the basic Windows "Notepad". Here's how to do it :
<ol>
 	<li>Right-click to any .PS1 file, and click "Open with":</li>
</ol>
<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/SetDefaultNotepadForPS1-1of2.png"><img alt="Fig.3" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/SetDefaultNotepadForPS1-1of2.png" /></a>
<ol start="2">
 	<li>Choose Notepad, and ensure the <code>[x] Always use this app to open .ps1 files</code> is checked :</li>
</ol>
<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/SetDefaultNotepadForPS1-2of2.png"><img alt="Fig.4" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/SetDefaultNotepadForPS1-2of2.png" /></a>
<ol start="3">
 	<li>You're done ! From now on, and until you change the default editor for .ps1 files, you'll see the "Run with PowerShell" context menu when you right-click a .PS1 file:</li>
</ol>
<a href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/blob/master/Screenshots/SetDefaultNotepadForPS1-Conclusion.png"><img alt="Fig.5" src="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator/raw/master/Screenshots/SetDefaultNotepadForPS1-Conclusion.png" /></a>
<a id="download"></a>
<h1><span>Download</span></h1>
<a target="_blank" href="https://gallery.technet.microsoft.com/Exchange-2010-2013-2016-bcd61dc7" rel="noopener">Download it on TechNet Gallery</a>

Or get it on the <a target="_blank" href="https://github.com/SammyKrosoft/Exchange-Recovery-Database-PowerShell-commands-generator" rel="noopener">tool's GitHub page</a>]]></content:encoded>
    </item>
    <item>
      <title>Autodiscover test tool - (c) from Kip Ng</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/autodiscover-test-tool-c-from-kip-ng</link>
      <pubDate>Mon, 28 May 2018 11:58:49 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5215</guid>
      <description><![CDATA[Hi all,

I was looking for a tool or a script that would help me to test the Exchange Autodiscover...]]></description>
      <content:encoded><![CDATA[Hi all,

I was looking for a tool or a script that would help me to test the Exchange Autodiscover process a bit like the <a target="_blank" href="https://testconnectivity.microsoft.com/" rel="noopener">Microsoft Remote Connectivity Analyzer</a> would do, but standalone and more dedicated to Exchange or O365 (Exchange Online) Autodiscover process. And I found this very practical, simple to use, useful <a target="_blank" href="https://blogs.technet.microsoft.com/provtest/2010/08/13/exchange-server-2010-sp1-beta-hosting-deployment-part-9-autodiscover/" rel="noopener">Autodiscover test tool</a> that Mr <a target="_blank" href="https://social.technet.microsoft.com/profile/Kip+Ng" rel="noopener">Kip Ng</a> created for us, thanks Kip ! <em>(Disclaimer: Kip is now my manager, but it's not the reason I'm buttering him up or backslapping: I'm just mentionning his work on this tool because it helped me more than once. However, I also have to mention that he's a handsome guy and a great manager :-p )</em>

As a reminder, Autodiscover process is the very first step that E-mail clients like Outlook perform when a user first launch it and/or tries to connect to his mailbox for the first time. See more information about <a target="_blank" href="https://technet.microsoft.com/en-us/library/bb124251(v=exchg.150).aspx?f=255&amp;mspperror=-2147217396" rel="noopener">Autodiscover here</a>. The process has not changed much since Exchange 2007...

This Autodiscover test tool works very well for Exchange 2010, 2013, 2016, as well as Exchange Online (O365) !

I won't write a lot about this tool as Mr. Kip Ng already describes it well on <a target="_blank" href="https://blogs.technet.microsoft.com/provtest/2010/08/13/exchange-server-2010-sp1-beta-hosting-deployment-part-9-autodiscover/" rel="noopener">his blog post</a>, but basically it will use the same process that Outlook (2010 -&gt; 2016) is using to find a user's mailbox connection settings, querying Autodiscover just like an Outlook client would do, and showing the results (the discovered URLs for OWA, ECP, EWS, UM, ...) on the command line window.

Here are the links on both his blog post and a direct download link for convenience:
<ul>
 	<li><a target="_blank" href="https://blogs.technet.microsoft.com/provtest/2010/08/13/exchange-server-2010-sp1-beta-hosting-deployment-part-9-autodiscover/" rel="noopener">Kip Ng's blog post about Autodiscover and the tool he created</a> (even if it's for Exchange Hosted, it works for all mailboxes hosted on Exchange 2010-&gt; 2016 onprem, as well as mailboxes hosted on Exchange Online in O365)</li>
 	<li><a target="_blank" href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/prod.evol.blogs.technet.com/telligent.evolution.components.attachments/01/6982/00/00/03/34/95/63/AutodiscoverTest.zip" rel="noopener">Direct download link to the Autodiscover test tool (Kip's Blog space)</a></li>
 	<li><a target="_blank" href="https://gallery.technet.microsoft.com/office/Autodiscover-test-tool-by-3393409b" rel="noopener">Alternate download link (TechNet Gallery)</a></li>
</ul>
&nbsp;

Here's an execution sample on my E2010 environment
<blockquote>Note: I tested on Exchange 2016 as well as on my corporate Exchange Online mailbox -&gt; all work good</blockquote>
<pre>C:\&gt;<strong>AutodiscoverTest.exe -email:User1@E2010Domain.com -username:User1@E2010Domain.com</strong>

Autodiscover Testing Utility:

AutodiscoverTest.exe -email:&lt;emailaddress&gt; [-allowselfsigned:{true|false}] [-username:&lt;username&gt;] [-password:&lt;password&gt;] [-url:&lt;autdiscover url&gt;]

where:

emailAddress - smtp address to autodiscover
 true|false - allow self signed certificates, default - false
 username - user name for https: requests authentication, eg. &lt;domain\user&gt; or
UPN
 password - user password for https: requestsauthentication
 url - specify a specific url for autodiscover test

If username/password/domain are not specified, default credentials are used.

----------------------------

Password not defined!
Please enter your password: ********

..starting Autodiscover test for 'User1@E2010Domain.com'
..using the specified credentials for HTTPS
..username: User1@E2010Domain.com
..domain:
..verifying E-mail address.
..starting SCP Lookup for domainName=E2010Domain.com
..Scanning for SCP urls for the current computer Site=SITE2
..SCP Url with other Site keyword found 'https://mail.e2010domain.com/autodiscover/autodiscover.xml'
..trying 'User1@E2010Domain.com' at 'https://mail.e2010domain.com/autodiscover/autodiscover.xml'

User/DisplayName=User1
User/LegacyDN=/o=E2010ORG/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=User14a8User/DeploymentId=37c0a5c5-1928-4ce9-a03d-e0b0e66cf138
Account/AccountType=email
Account/Action=settings
Account/Protocol/Type=EXCH
Account/Protocol/ASUrl=https://mail.e2010domain2.com/ews/exchange.asmx
Account/Protocol/DirectoryPort=0
Account/Protocol/MdbDN=/o=E2010ORG/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=Outlook.contoso.com/cn=Microsoft Private MDBAccount/Protocol/OABUrl=https://mail.e2010domain2.com/oab/ef0acab4-4923-499b-86ed-413979af4c74/
Account/Protocol/OOFUrl=https://mail.e2010domain2.com/ews/exchange.asmx
Account/Protocol/Port=0
Account/Protocol/ReferralPort=0
Account/Protocol/Server=Outlook.contoso.com
Account/Protocol/ServerDN=/o=E2010ORG/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=Outlook.contoso.com
Account/Protocol/ServerVersion=7383807B
Account/Protocol/UMUrl=https://mail.e2010domain2.com/ews/UM2007Legacy.asmx
Account/Protocol/PublicFolderServer=E2010-NODE2.E2010Domain.com
Account/Protocol/AD=E2010ENV-GC1.E2010Domain.com
Account/Protocol/EwsUrl=https://mail.e2010domain2.com/ews/exchange.asmx
Account/Protocol/EcpUrl=https://mail.e2010domain2.com/ecp/
Account/Protocol/EcpUrl-um=?p=customize/voicemail.aspx&amp;exsvurl=1
Account/Protocol/EcpUrl-aggr=?p=personalsettings/EmailSubscriptions.slab&amp;exsvurl=1
Account/Protocol/EcpUrl-mt=PersonalSettings/DeliveryReport.aspx?exsvurl=1&amp;IsOWA=&lt;IsOWA&gt;&amp;MsgID=&lt;MsgID&gt;&amp;Mbx=&lt;Mbx&gt;
Account/Protocol/EcpUrl-ret=?p=organize/retentionpolicytags.slab&amp;exsvurl=1
Account/Protocol/EcpUrl-sms=?p=sms/textmessaging.slab&amp;exsvurl=1
Account/Protocol/Type=EXPR
Account/Protocol/AuthPackage=Basic
Account/Protocol/DirectoryPort=0
Account/Protocol/OABUrl=https://mail.e2010domain2.com/oab/ef0acab4-4923-499b-86ed-413979af4c74/
Account/Protocol/Port=0
Account/Protocol/ReferralPort=0
Account/Protocol/Server=mail.e2010domain.com
Account/Protocol/SSL=On
Account/Protocol/Type=WEB
Account/Protocol/DirectoryPort=0
Account/Protocol/Port=0
Account/Protocol/ReferralPort=0
Account/Protocol/Internal/OWAUrl[@AuthenticationMethod="Basic, Ntlm, Fba, WindowsIntegrated"]=https://mail.e2010domain2.com/owa/
Account/Protocol/Internal/Protocol/Type=EXCH
Account/Protocol/Internal/Protocol/ASUrl=https://mail.e2010domain2.com/ews/exchange.asmx</pre>]]></content:encoded>
    </item>
    <item>
      <title>Event Logs CSV Collector: Created a Graphical User Interface around the Get-EventsFromEventLogs.ps1 script</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/event-logs-csv-collector-created-a-graphical-user-interface-around-the-get-eventsfromeventlogs-ps1-script</link>
      <pubDate>Wed, 23 May 2018 11:26:56 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=5175</guid>
      <description><![CDATA[*** Edited - added a function to check for Powershell V3 (Function IsPSV3 () - required) and exit if...]]></description>
      <content:encoded><![CDATA[*** Edited - added a function to check for Powershell V3 (<em>Function IsPSV3 () - required</em>) and exit if not ***

Hi mates,

&nbsp;

This is just a quick post to let you know that if you would prefer some mouse interaction and a more graphical input for the <a target="_blank" href="https://blogs.technet.microsoft.com/samdrey/2018/04/13/powershell-script-to-export-events-to-screen-andor-to-file-from-one-or-multiple-machines/" rel="noopener">Get-EventsFromEventLogs script</a>.

Basically, this GUI will let you fill the Computers, the Event ID and/or the Event Sources, as well as the Event Log types you wish to search in (Application and/or System and/or Security - note that for the "Security" event logs, you need Local Admin permissions on whichever machine you want to collect these), and the Events Level you want to search or export.

As you fill the boxes and check the options, you'll see the command line that will built itself as options are checked or unchecked, and as input boxes (Servers, Event ID(s), Event Sources) are filled or cleared:

<img src="https://msdnshared.blob.core.windows.net/media/2018/05/Get-EventsFromEventLogsG-GUI-CmdLineGenerator.png" />
<blockquote><em>NOTE: the "auto-fill" part of the PowerShell script is not more than a function that is called each time a mouse "click" event is registered on the Graphical Interface, and each time the text inside a box is changed, and that function checks all the WPF form controls (a control is a check box, or an inputbox, or a button, etc... it's an element of the form a user can interact with) and update the text in the "<strong>Function Command Line</strong>" box each time a "click" or "text changed" event is detected on the WPF form.</em></blockquote>
Here's the whole interface:

<a href="https://msdnshared.blob.core.windows.net/media/2018/05/Get-EventsFromEventLogsG-GUISample.png"><img width="790" height="497" class="alignnone size-full wp-image-5145" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/Get-EventsFromEventLogsG-GUISample.png" /></a>
<blockquote><em>NOTE: when the "<strong>[X] Save events to file</strong>" checkbox is checked, the program will automatically save your results on a file on the same directory where the script is located, and open up the file in NOTEPAD at the end of the execution. If you leave this unchecked, the results will just be printed in the underlying PowerShell window (that's great to have an overview of the events as well as a summary of the Errors / Warnings / Critical / Information events before saving these in to a file for further analysis - with PowerBI Template for example :-) )</em><img /></blockquote>
&nbsp;
<blockquote><em>NOTE2: by default, if you don't specify a computers list, and if you don't check any log types (App / Sys), the program will check and display the 30 last events of the local machine where the script is executed, from the Application and System event logs.</em></blockquote>
&nbsp;
<blockquote><em>NOTE3: the "Speech" section is in alpha version for now, as 1) I didn't translate every messages into both French and English, and 2) PowerShell will wait until the computer finishes to speak before releasing the interface to you, and I made it speak each time you check a box ... </em></blockquote>
&nbsp;

You can <strong><a target="_blank" href="https://gallery.technet.microsoft.com/GUI-to-search-export-to-6d412882?redir=0" rel="noopener">download the PowerShell Events Collector GUI here</a></strong> - note that I also include the PowerBI Template in the archive, it's optional to use, just in case you'll like to test using PowerBI with event logs analysis some time...

Have a great one,
Cheers
Sam]]></content:encoded>
    </item>
    <item>
      <title>How To: Use a PowerBI template to analyze Event Logs exported as a CSV file</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/how-to-use-powerbi-event-log-analysis-template-with-your-own-events-csv-file</link>
      <pubDate>Fri, 04 May 2018 20:08:17 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=4915</guid>
      <description><![CDATA[Prerequisites/Ingredients

 	PowerBI Desktop – You can download it here
 	The PowerBI Event Log...]]></description>
      <content:encoded><![CDATA[<h1>Prerequisites/Ingredients</h1>
<ul>
 	<li><strong>PowerBI Desktop</strong> – You can <a target="_blank" href="https://powerbi.microsoft.com/en-us/desktop/" rel="noopener">download it here</a></li>
 	<li>The<strong> PowerBI Event Log analysis template</strong> - You can <a target="_blank" href="https://msdnshared.blob.core.windows.net/media/2018/05/Event_Dump_Analysis_Template.zip" rel="noopener">download it here</a> - it is a .PBIT format, you'll have to unzip it.</li>
 	<li><strong>Windows Powershell</strong> (from 2.0 – Windows 2008/2008R2 up to 5.2- Windows 2016)
<strong>or Powershell 6</strong> (<a target="_blank" href="https://github.com/PowerShell/PowerShell/releases" rel="noopener">https://github.com/PowerShell/PowerShell/releases</a>)</li>
 	<li>The <strong>Get-EventsFromEventLogs.ps1 PowerShell script</strong> – You can <a target="_blank" href="https://gallery.technet.microsoft.com/View-or-Export-To-CSV-62ebd49c" rel="noopener">download it here</a></li>
</ul>
Before loading the PowerBI template I made for you, you must have a CSV collected with the Get-EventsFromEventLogs.ps1 script. See the following sections…
<h1>Collect your events using the Get-EventsFromEventLogs script</h1>
Collect the events from your servers using the <a href="https://gallery.technet.microsoft.com/View-or-Export-To-CSV-62ebd49c">Get-EventsFromEventLogs.ps1 script</a>, preferably using the following parameters – just replace the <strong>Server01, Server02</strong> with <strong>your computers</strong>, or the content of a <strong>Computers.txt</strong> file:
<pre><span style="font-family: Courier New"><strong><span style="color: #333333"><span style="background-color: whitesmoke">.\Get-EventsFromEventLogs.ps1 -Computers Server01,Server02 -EventLevel Warning,Error,Critical -NumberOfLastEventsToGet 200 <span style="background-color: whitesmoke">–ExportToFile</span></span></span></strong></span></pre>
Note: to get the computers list from a text file use the following syntax just after the -Computers parameter :
<pre><span style="font-family: Courier New"><strong>-Computers $(Get-Content C:\temp\Computers.txt)</strong></span></pre>
The exported CSV file will be located on the same directory where you placed your <span style="font-family: Courier New"><strong>Get-EventsFromEventLogs.ps1</strong></span> script, and will be named like <strong>"<span style="font-family: Courier New">GetEventsFromEventLogs_blabla-Date-Time.csv</span></strong>"
<h1>Get the PowerBI template</h1>
The template created to work with the file exported with the Get-EventsFromEventLogs.ps1 script is named :
<pre><span style="font-family: Courier New;font-size: 12pt"><strong> Event_Dump_Analysis_Template.pbit</strong></span></pre>
See the prerequisites above for the download link - I'm placing <a target="_blank" href="https://msdnshared.blob.core.windows.net/media/2018/05/Event_Dump_Analysis_Template.zip" rel="noopener">here </a>for convenience in case you forgot to go through the prerequisites.
<h1>Open the PowerBI Template (PBIT) and point it to your CSV Events file</h1>
<strong>NOTE</strong>: you will need the CSV file that was generated by the <span style="font-family: Courier New"><strong>Get-EventsFromEventLogs.ps1</strong></span> script introduced on section 2 above…

Open it -&gt; <strong>you will have an error</strong> just after PowerBI Desktop loaded =&gt; it is expected because we didn't specify the <strong>GetEventsFromEventLogs-xxxx-xxxx-xxx.CSV</strong> file to analyze yet ! It's coming on next step.

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow1.png" />

Here's the <strong>expected error</strong> you'll get because at this point we didn't load our correct CSV file (<em>I had to put a dummy value on the "URI" field to create the template because PowerBI doesn't have the functionality to request a CSV file prior to load the template for now</em>):

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow2.png" />

Click "<strong>Close</strong>" -&gt; you'll see the first page of the report with blank values (because you didn't load your CSV yet !):

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow3.png" />

Click on "<strong>Edit Queries</strong>" button – I'm highlighting the button below so that you can't miss it :

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow4.png" />

This will open the "<strong>Power Query Editor</strong>" window:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow5.png" />

See the "<strong>APPLIED STEPS</strong>" on the far right of the screen above? Here's a closeup of it:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow6.png" />

And a bit closer:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow7.png" />

There is an entry in the list called "<strong>Source</strong>" with a configuration gear beneath it

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow8.png" />-&gt; click on the configuration gear of the "<strong>Source</strong>" entry, which will lead you there:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow9.png" />

Closeup of the field we'll need to change:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow10.png" />

See the value you see in "<strong>URL</strong>" (default is <span style="font-family: Courier New;font-size: 12pt">.\GetEventsFromEventLog.csv</span>, which is purposely invalid) =&gt; Change it to the path to the CSV file generated by your <span style="font-family: Courier New;font-size: 12pt">Get-ExchangeFromEventLogs.ps1</span> script – here I'll take my CSV file located in my <span style="font-family: Courier New">C:\TEMP\</span> directory, and which I renamed MyEvents.CSV – I'll then specify in the "URL" field "<span style="font-family: Courier New;font-size: 12pt">C:\TEMP\MyEvents.CSV</span>" – This is an example, just put your actual full CSV path and file name :

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow11.png" />

Click "<strong>OK</strong>" -&gt; you should see the first elements of your CSV on the "Power Query Editor" window:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow12.png" />

And click on the "<strong>Close and Apply</strong>" button on the upper left corner of the "<strong>Home</strong>" ribbon menu:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow13.png" />

And Magic Happens ! Your PowerBI report will be filled with the stats from your collected CSV !

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow14.png" />

Navigate to the other tabs to see your events stats, click on the bars and/or on the servers to see the information filtered dynamically.
<pre>-------------------------- EXAMPLE 1 --------------------------</pre>
The "Errors only for each server" tab:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow15.png" />

Click on the first bar (you'll see 1 bar per server – if you have 40 servers, you'll see 40 bars showing the number of Event Logs errors per server), and see the below table filtering dynamically to the error events that belong to that server only :

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow16.png" />

Same principle if you click an event in the below table, for example the first line that has 356 errors for my MSExchangeRepl service, it will show on which server these are distributed :

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow17.png" />
<pre>-------------------------- EXAMPLE 2 --------------------------</pre>
Let's see the "Errors/Warnings per provider name" tab :

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow18.png" />

Here I have all the Errors and Warnings filtered in this page, shown by "Event Source" aka "Provider Name" (I should have renamed it). Same here, you can click either on one event on the below table to see the distribution per server or like the example below, on one of the category for which you'd like to see the errors and which server has this event – below I clicked on "<em>Service control manager</em>"

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow19.png" />
<pre>-------------------------- EXAMPLE 3 --------------------------</pre>
Finally, you can dig a bit more and check for the details of event logs with the last tab "<strong>Fine analysis – All events</strong>" – you can select a "<strong>ProviderName</strong>" aka "<strong>Event Source</strong>", or a server (one of the two bars below), or an event, and see what it does – below is the table before clicking on a "ProviderName":

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow20.png" />

And below the table after clicking on the "ESE" Provider Name aka Event Source:

<img alt="" src="https://msdnshared.blob.core.windows.net/media/2018/05/050518_0112_HOWTOUsePow21.png" />

You see I have this event on only 1 of my servers (1 bar show up when I click on "ESE") …

Have fun !

Cheers

Sam]]></content:encoded>
    </item>
    <item>
      <title>PowerShell scripts to Migrate Exchange Mailbox and Distribution Group Send As, Full Access and Send On Behalf Permissions into a CSV file–Part I : Export Script</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/powershell-script-to-migrate-exchange-mailbox-and-distribution-group-send-as-full-access-and-send-on-behalf-permissions-into-a-csv-file-part-i-export-script</link>
      <pubDate>Sun, 29 Apr 2018 22:42:47 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=4635</guid>
      <description><![CDATA[Hi !

This post is to introduce a script to export Mailbox Send As, Full Access and Send On Behalf...]]></description>
      <content:encoded><![CDATA[Hi !

This post is to introduce a script to export Mailbox Send As, Full Access and Send On Behalf permissions, and also Distribution Group Send As and Send On Behalf permissions into a CSV file, to help you achieve the following objectives:
<ul>
 	<li>You wish to audit the permissions globally set to your mailboxes across the whole organization –&gt; export the permissions, and analyze these within Excel with the power of “Format As Table”, filtering, pivot tables, … and why not, make executive reports of these permissions with our powerful <a href="https://powerbi.microsoft.com/en-us/">PowerBI</a> ! I'll also blog later on this one for a couple of examples...</li>
 	<li>You wish to migrate your mailboxes and your Distribution Groups to another forest, and you wish to keep the Send As, Full Access and Send On Behalf permissions. That’s in case you’re migrating your mailboxes cross forest not using the New-MoveRequest cmdlet cross forest, because these will keep those permissions (see <a target="_blank" href="https://blogs.technet.microsoft.com/exchange/2010/08/10/exchange-2010-cross-forest-mailbox-moves/" rel="noopener">this older but still accurate post from the Exchange Product Team for more information</a>)</li>
</ul>
This is the Part I which introduces and gives you the script to export the Mailbox / Distribution Groups permissions, named Export-MailboxFASAPermissions.ps1 ("FASA" stands for Full Access and Send As - although the scripts include the export/import of the Send On Behalf permissions as well). I'll refer to that script as to EXPORT script in this articles quick series (Export/Import - a bit equivalent to Migrate).

The Part II will come later and introduce the Import-MailboxFASAPermissions.ps1. I’ll refer to this Import-MailboxFASAPermissions.ps1 as to “IMPORT script”.
<blockquote><strong>NOTE 1</strong>: in the case of permissions "migration", which is nothing else than an Export of the permissions from an environment, to later import these to a target environment. The key used to match users between the source forest and the target forest will be the <strong>user SMTP address</strong> for the mailboxes to re-populate with permissions – because <strong>an SMTP address uniquely identifies a mailbox.</strong>

<strong>NOTE 2</strong>: When exported with Get-ADPermission or Get-MailboxPermission, the Send As and Full Access permissions are referenced with DOMAIN\Alias of the users. When exported with Get-Mailbox, GrandSendOnBehalfTo permissions are referenced with the DOMAIN/OU1/SUB-OU/Alias type notation.</blockquote>
The EXPORT script exports the<strong> Send As</strong> and <strong>Full Access</strong> permissions in the form <strong>DOMAIN\Alias</strong>. If you import in a different forest, the IMPORT script will let you specify a domain to populate these permissions in the form of <strong>TARGET_DOMAIN\Alias</strong> - easily achieved by splitting the SOURCE_DOMAIN\alias string using the "\" as a separator, and concatenating the "alias" with the "TARGET_DOMAIN" using PowerShell's "-Join" of "$MyArray.Join("\")" method (by default the IMPORT Script will import these permissions as they were on the source environment, using SOURCE_DOMAIN\Alias).
<blockquote><strong>NOTE 3:</strong> GrantSendOnBehalfTo can only be given to Mailbox-Enabled users, Mail-Enabled Users, or Mail-Enabled Security Groups. These are exported in the notation indicated in NOTE 2, but the script converts these to their SMTP Address – remember the GrantSendOnBehalfTo can only contain Mailbox-Enabled users, Mail-enabled users or mail-enabled security groups =&gt; that way, the Get-Recipient cmdlet resolves the DOMAIN/OU1/SUB-OU/…/Alias into an SMTP address =&gt; since an SMTP address uniquely identify a recipient, converting the DOMAIN/OU/…/Alias notation to an SMTP address in the CSV file simplifies the Import as well, as we will just use Set-Mailbox &lt;MailboxSMTPAddress&gt; –GrantSendOnBehalfTo “User1SMTPAddress”, “User2SMTPAddress”, “…” which will work provided the UserxSMTPAddress exist in the target environment.</blockquote>
&nbsp;

As an important usage note, you'll notice on the Get-Help dump below that the script has 3 syntaxes:
<ul>
 	<li>One that exports Shared and Resource mailboxes only</li>
</ul>
<pre>.\Export-MailboxFASAPermissions.ps1 -SharedMailboxes -ResourceMailboxes</pre>
<ul>
 	<li>One that exports Distribution group with the option to Include or not the Dynamic Distribution groups</li>
</ul>
<pre>.\Export-MailboxFASAPermissions.ps1 -DistributionGroupsOnly -IncludeDynamic $true/$false</pre>
<ul>
 	<li>One that checks the script version</li>
</ul>
<pre>.\Export-MailboxFASAPermissions.ps1 -CheckVersion</pre>
There is one other use which is just launching the script without options:
<pre>.\Export-MailboxFASAPermissions.ps1</pre>
This will export all the Mailboxes permissions.

Here’s the help of the EXPORT script – the download link is at the very end of the help dump:
<pre>PS&gt;get-help .\Export-MailboxFASAPermissions.ps1 -full

NAME
     .\Export-MailboxFASAPermissions.ps1
     
SYNOPSIS
     Export Exchange Mailbox Send As, Full Access, and Send On Behalf permissions
     in a CSV file in order to later import them in another environment using the 
     output CSV file.
     
     
SYNTAX
     .\Export-MailboxFASAPermissions.ps1 [[-SharedMailboxes]] [[-ResourceMailboxes]] [[-OutputFile] &lt;String&gt;] [&lt;CommonParameters&gt;]
     
     .\Export-MailboxFASAPermissions.ps1 [[-DistributionGroupsOnly]] [[-IncludeDynamic] &lt;Boolean&gt;] [&lt;CommonParameters&gt;]
     
     .\Export-MailboxFASAPermissions.ps1 [[-CheckVersion]] [&lt;CommonParameters&gt;]
     
     
DESCRIPTION
     This script requires the Exchange tools to run.
     
     It exports the following Exchange Mailbox permissions in a CSV file 
     - Send As
     - Full Access
     - Send On Behalf To
     in order to be able to import them later in another environment using 
     the output CSV file.
     
     The Output CSV file will contain the following information for each mailbox permissions
     information exported:
     
     Display Name, Primary SMTP Address, Full Access permissions, Send As permissions, Send On Behalf permissions
     
     The permissions can have one or more entries, which will be separated by semicolons (";")
     
     To import back the permissions if needed , you can use the associated Import-MailboxFASAPermissions.ps1 
     script.
     
     Since the Send As and Full Access permissions can be granted to non-mailbox or
     non-mail enabled users, these are stored in the CSV in the form of DOMAIN\Alias.
     
     On the other hand, the Send On Behalf permission can be granted only to mailbox-enabled users,
     mail-enabled users and/or mail-enabled security groups only. For some reason, it is stored in 
     the form of DOMAIN\OU1\Sub-OU1\...\Name - then, the script is designed to convert these - actually
     the script resolve these using Get-Mailbox -Identity DOMAIN\OU\...\Name to get and store the
     PrimarySMTPAddress of these users so that we have two advantages:
         &gt; Not only we are sure that each SMTP address represents a unique user
         &gt; Also it will be way easier for the IMPORT script to import these permissions back, wherever OU the
         target user will be located !
     
     This is because the IMPORT script uses Set-Mailbox with the -SendOnBehalfTo, where we can
     specify an SMTP address, which will be converted to the corresponding DOMAIN\OU\Name of the 
     corresponding user in the target environment.
     
     In other words, the SMTP address will be the KEY to match the SendOnBehalfTo permission to the
     right users and mailboxes on the target environments.
    

PARAMETERS
     -SharedMailboxes [&lt;SwitchParameter&gt;]
         This indicates the script to export the SharedMailboxes only
         
         When combined with the -ResourceMailboxes, the script will export
         the Shared Mailboxes, and the Room and Equipment Mailboxes as well !
         
         To export ALL mailboxes, just don't specify neither the SharedMailboxes
         nor the ResourceMailboxes parameter.
         
         Required?                    false
         Position?                    1
         Default value                False
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     -ResourceMailboxes [&lt;SwitchParameter&gt;]
         This indicates the script to export the ResourceMailboxes only which
         consist of the Room and the Equipment Mailboxes.
         
         When combined with the -SharedMailboxes, the script will export the
         Shared Mailboxes, the Room and the Equipment mailboxes as well !
         
         To export ALL mailboxes, just don't specify neither the SharedMailboxes
         nor the ResourceMailboxes parameter.
         
         Required?                    false
         Position?                    2
         Default value                False
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     -DistributionGroupsOnly [&lt;SwitchParameter&gt;]
         
         Required?                    false
         Position?                    4
         Default value                False
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     -IncludeDynamic &lt;Boolean&gt;
         
         Required?                    false
         Position?                    5
         Default value                True
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     -OutputFile &lt;String&gt;
         Sets the file to which we want to store the results.
         By default, the script will generate a CSV report with the name of the script, 
         with the date and time appended to it.
         
         Required?                    false
         Position?                    6
         Default value                
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     -CheckVersion [&lt;SwitchParameter&gt;]
         This parameter just dumps the script version.
         
         Required?                    false
         Position?                    7
         Default value                False
         Accept pipeline input?       false
         Accept wildcard characters?  false
         
     &lt;CommonParameters&gt;
         This cmdlet supports the common parameters: Verbose, Debug,
         ErrorAction, ErrorVariable, WarningAction, WarningVariable,
         OutBuffer, PipelineVariable, and OutVariable. For more information, see 
         about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). 
     
INPUTS
     The script will scan all the mailboxes, but database by database to avoid to use
     all the RAM of the machine from which it's executed.
     
     
OUTPUTS
     A CSV file with either a name that you specify with the OutputFile parameter, or if not,
     the name of the script, containing the users Display Names, primary SMTP addresses,
     and the list of Send-As, Full Access and SendOnBehalfTo for each of these mailboxes.
     
     If the Send-As, Full Access and SendOnBehalfTo are multi-values, they are stored in the columns
     as semi-colon separated values, like Value1;value2;value3;...
     
     =&gt; when processing each permissions set, just use something like $ImportedCSV.SendAsPermissions -split ";" 
     or $ImportedCSV.SendAsPermissions.Split(";") ...
     
     
NOTES
     
     
         This script can be use alone to export a permissions map, but the output is designed so that it
         can be used with the Import-MailboxFASAPermissions.ps1 script to migrate permissions to another
         environment such as a LAB or a brand new one with the same users (Inter-Forest migration for example
         or move from an On-Prem to an outsourced environment such as Office 365)
         
         Some simple facts about the permissions exported on this script:
         
         "Sens As" permissions
             . Stored in the form of "DOMAIN\Alias"
             . Is set with Add-ADPermission
             . <a href="https://docs.microsoft.com/en-us/powershell/module/exchange/active-directory/Add-ADPermission?view=exchange-ps">https://docs.microsoft.com/en-us/powershell/module/exchange/active-directory/Add-ADPermission?view=exchange-ps</a>
         
         "Full Access" Permissions
             . Stored in the form of "DOMAIN\Alias" as well
             . Is set with Add-MailboxPermission
             . <a href="https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/Add-MailboxPermission?view=exchange-ps">https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/Add-MailboxPermission?view=exchange-ps</a>
         
         "Send On Behalf Of" permissions
             . Stored in the form of "Domain.com/OU_Name/Sub_OU/Name"
             . Is set with Set-Mailbox
             . <a href="https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/Set-Mailbox?view=exchange-ps">https://docs.microsoft.com/en-us/powershell/module/exchange/mailboxes/Set-Mailbox?view=exchange-ps</a>
             . -GrantSendOnBehalfTo parameter accepts one or more values from the below :
                     Display name
                     Alias
                     Distinguished name (DN)
                     Canonical DN
                     &lt;domain name&gt;\&lt;account name&gt;
                     Email address
                     GUID
                     LegacyExchangeDN
                     SamAccountName
                     User ID or user principal name (UPN)
     
     -------------------------- EXAMPLE 1 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASAPermissions.ps1
     
     Will run the script and export the mailbox Display Names, primary SMTP Addresses, and all the
         Send As, Full Access and Send On Behalf To permissions on a CSV file.
     
     
     
     
     -------------------------- EXAMPLE 2 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASAPermissions.ps1 -OutputFile C:\temp\EnvironmentPermissions.csv
     
     Will run the script and export permissions for all mailboxes, in the file specified on the 
         OutputFile parameter : C:\temp\EnvironmentPermissions.csv
     
     
     
     
     -------------------------- EXAMPLE 3 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASA.ps1 -SharedMailboxes
     
     Will run the script and export the Shared Mailboxes permissions as well as the Room and
         Equipment Mailboxes permissions, and store the result on the default CSV file named after
         the script, appended with the date and time of the execution, on the script directory
     
     
     
     
     -------------------------- EXAMPLE 4 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASA.ps1 -ResourceMailboxes c:\temp\ResourceMailboxPermissions.csv
     
     Will run the script and export only the Room and Equipment Mailboxes permissions, and store
         the results in a CSV file c:\temp\ResourceMailboxPermissions.csv
     
     
     
     
     -------------------------- EXAMPLE 5 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASA.ps1 -DistributionGroupsOnly
     
     Will run the script and export only the Distribugion Group permissions (Send As, GrantSendOnBehalfTo) in 
         the default Output file format (Script_Name_Date_time.csv). This includes the Dynamic Distribution 
         Groups.
     
     
     
     
     -------------------------- EXAMPLE 6 --------------------------
     
     PS C:\&gt;.\Export-MailboxFASA.ps1 -DistributionGroupsOnly -IncludeDynamic $false
     
     Will run the script to export permissions of Distribution Groups, excluding the Dynamic Distribugion
         Groups.
     
     
     
     
     
RELATED LINKS
     <a href="https://technet.microsoft.com/en-ca/library/jj919240(v=exchg.150).aspx">https://technet.microsoft.com/en-ca/library/jj919240(v=exchg.150).aspx</a>
     <a href="https://docs.microsoft.com/en-us/powershell/module/exchange/active-directory/add-adpermission?view=exchange-ps">https://docs.microsoft.com/en-us/powershell/module/exchange/active-directory/add-adpermission?view=exchange-ps</a>
     <a href="https://technet.microsoft.com/en-us/library/jj919240(v=exchg.150).aspx">https://technet.microsoft.com/en-us/library/jj919240(v=exchg.150).aspx</a>
     https://github.com/SammyKrosoft</pre>
&nbsp;

<a href="https://gallery.technet.microsoft.com/Export-Mailbox-and-0654fa53"><span style="text-decoration: underline"><strong>CLICK HERE TO GO TO THE TECHNET GALLERY TO DOWNLOAD THIS SCRIPT...</strong></span></a>]]></content:encoded>
    </item>
    <item>
      <title>PowerShell–Script to export events to screen and/or to a CSV file from one or multiple machines</title>
      <link>https://docs.microsoft.com/archive/blogs/samdrey/powershell-script-to-export-events-to-screen-andor-to-file-from-one-or-multiple-machines</link>
      <pubDate>Fri, 13 Apr 2018 09:55:52 GMT</pubDate>
      <dc:creator><![CDATA[SammyKrosoft]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.technet.microsoft.com/samdrey/?p=4205</guid>
      <description><![CDATA[*** UPDATE *** Added a GUI wrapped around this script - you can check it out here ...

Type the...]]></description>
      <content:encoded><![CDATA[<span style="color: #ff0000;font-size: medium">*** UPDATE *** Added a GUI wrapped around this script - you can <a href="https://gallery.technet.microsoft.com/GUI-to-search-export-to-6d412882?redir=0">check it out here</a> ...</span>

Type the following to see the latest examples:
<pre>Get-Help .\Get-EventsFromEventLogs.ps1 –Examples</pre>
Type the following to see the full help:
<pre>Get-Help .\Get-EventsFromEventLogs.ps1 –Full</pre>
&nbsp;

Hi all !

<span style="font-size: medium">Today I’ll give you a script that exports the events of your choice (you chose one or more Event IDs you want to export or one or more Event Sources), from one or multiple computers or servers. In this script I am also fixing events which description has carriage returns to ease up the Excel processing as I noticed when exporting Event logs as CSV from the Windows Event Viewer, events which descriptions had carriage returns were spanned across several Excel rows.</span>

<span style="font-size: small"><span style="font-size: medium">By default, the script will only output the events found on screen. You must specify the <span>–ExportToFile</span> switch to export the events found on a CSV file. This CSV file will be located in the same directory where the script is located, and will be formatted like the below - it will have the name or number of the first event D or source that you are searching the logs for:</span></span>
<pre><span><span>GetEventsFromEventLogs_EventIDorEventSource_Year-MONTH-DAY-Hour-Minute-Second.csv</span></span></pre>
<span><span><strong>
- Example:</strong></span></span>
<blockquote>Launching
<pre>.\Get-EventsFromEventLogs.ps1 -Computers Server01,Server02 -EventLevel Error,Critical –ExportToFile</pre>
got me the below file - with before the date the first event ID I was looking for:
<pre>GetEventsFromEventLogs_916_2018-04-13-09-52-08.csv</pre>
Located on the same directory where my script is …</blockquote>
<span style="font-size: small"><strong><span style="font-size: medium">- Other Example of the script’s full execution:</span></strong></span>
<blockquote>
<pre><span>.\Get-EventsFromEventLogs.ps1 -Computers $(Get-ExchangeServer) –EventLogName Application -EventSource "MSExchange ADAccess","MSExchangeADTopology" -NumberOfLastEventsToGet 30 -EventLevel Warning,Error -ExportToFile</span></pre>
<span style="font-size: medium">Note here that I am passing in the <em><strong>–Computers</strong></em> parameter all my Exchange Mailbox servers by using <em><strong>$(Get-MailboxServer)</strong></em> to check all my Exchange servers =&gt; in order for this to work, you must execute the script from an Exchange Management Shell-enabled PowerShell session – otherwise, you can specify a list of computers (<em><strong>-Computers EX01,EX02</strong></em>) or get a list of computer from a file (<em><strong>-Computer $(Get-Content C:\temp\MyServers.txt)</strong></em>)</span>

<span style="font-size: medium">First, I will get the confirmation of the options of the script and I am asked to validate to continue:</span></blockquote>
<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-1-Confirm-parameters.png"><img width="651" height="175" class="alignnone wp-image-4565 size-full" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-1-Confirm-parameters.png" /></a>
<blockquote><span style="font-size: small"><span style="font-size: medium">Then it will run and show me what it’s doing:</span></span></blockquote>
<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-2-Script-Completed-and-stats.png"><img width="995" height="506" class="alignnone size-full wp-image-4595" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-2-Script-Completed-and-stats.png" /></a>
<blockquote>Note that it searches on all computers I specified, displays warnings and errors (30 last events for each machine, as I specified in the script's <strong>–NumberOfLastEventsToGet</strong> parameter) from the 2 servers I have in my environment…

Also Note the summary of all the events found globally at the end of the script.

And finally note how quick it is to search and dump our events ! About half a second !</blockquote>
<blockquote><span style="font-size: small"><span style="font-size: medium">And as it finishes, it opens me the file in a NOTEPAD because I specified the <strong>–ExportToFile</strong> switch on the script launch:</span></span></blockquote>
<a href="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-3-Notepad-and-raw-CSV-view.png"><img width="1248" height="249" class="alignnone size-full wp-image-4575" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-3-Notepad-and-raw-CSV-view.png" /></a>
<blockquote>You can also open the file (or copy/paste the Notepad content) with Excel for filtering, analyzing, correlating, reporting, etc…</blockquote>
<span style="font-size: small"> <a href="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-4-Excel-CSV-view.png"><img width="1708" height="759" class="alignnone size-full wp-image-4605" alt="" src="https://msdnshared.blob.core.windows.net/media/2018/04/Figure-4-Excel-CSV-view.png" /></a></span>

<span style="font-size: small"><strong><span style="font-size: large"> </span></strong></span>

<span style="font-size: small"><strong><span style="font-size: large">Here are the switches you can use:</span></strong></span>
<pre><strong><span></span></strong><strong><span><span style="font-size: medium">-Computers &lt; Object&gt;</span></span></strong><strong><span></span></strong></pre>
<span style="font-size: medium">=&gt; <em><strong>where &lt;Object&gt; default = local computer</strong></em>, <strong><u> you can specify list of computers</u></strong>, strings separated by commas like <strong>-Computers “Server1”, “Server2”,”Server3”</strong> or get the computers from a list like<strong> -Computers $(Get-Content C:\temp\myservers.txt)</strong> or get the computers from a variable that contains a list of Exchange servers, etc…</span>

<span style="font-size: small"><span style="font-size: medium">I tried the below on my Exchange 2013 environment :</span></span>
<pre><span>.\Get-EventsFrom.ps1 <strong>-Computers $(Get-MailboxServer)</strong> -EventIDToCheck 2142 -EventLogName Application -ExportToFile</span></pre>
<span style="font-size: small"><span style="font-size: medium">And it got my last 30 events with Event ID 2142 from all my Exchange servers of my environment !</span></span>
<pre><span style="font-size: small"><strong><span><span style="font-size: medium"> </span></span></strong></span><span style="font-size: small"><strong><span><span style="font-size: medium">-EventLogName &lt; Object&gt;</span></span></strong><strong><span></span></strong></span></pre>
<span style="font-size: small"><span style="font-size: medium">=&gt; <em><strong>where &lt;Object&gt; default = Application and System logs</strong></em>, you can specify the Application LOG only (<em><strong>-EventLogName Application</strong></em>) or specify several event log types separated by commas (<em><strong>-EventLogName Application,  System, Security</strong></em>) </span></span>

<span><em>There is a defined set of Event Log Names that you can use, you can cycle through the valid values for this parameter by hitting &lt;<strong>TAB&gt;</strong> after you specify the <strong>–EventLogName</strong> parameter, and event hitting &lt;TAB&gt; for multiple values will cycle through each possible Event Log Name value. I love that PowerShell parameter validation functionality ! &lt;3</em></span>
<pre><strong>-EventLevel &lt;Level&gt;</strong></pre>
Level must be Information, Warning, Error, and/or Critical. You can specify multiple events type, by separating with commas, like:
<pre>.\Get-EventsFromEventLogs -EventLevel Warning,Error -ComputerName Computer01,Computer02</pre>
If you don't specify anything, all event types will be gathered (by default the first 30 events from each computer)

-EventSource &lt;String&gt;

This can be any source which Event you wish to dump. Example if you are looking for potential warnings and/or errors in Outlook from the local workstation you would use the below :
<pre>.\Get-EventsFromEventLogs -EventLevel Warning,Error -EventSource Outlook</pre>
&nbsp;
<pre><span style="font-size: small"><strong><span><span style="font-size: medium"> </span></span></strong></span><span style="font-size: small"><strong><span><span style="font-size: medium">-EventID &lt; Object&gt;</span></span></strong><strong><span></span></strong></span></pre>
<span style="font-size: small"><span style="font-size: medium"><em><strong><span>=&gt; where &lt;Object&gt; default = “All” </span>, if you don’t specify it, the script will search for all Event IDs</strong></em>, and if you want you can specify a list of IDs to search for or to check : just enter each Event ID separated by commas (like <em><strong>-EventID 1220,2020,605</strong></em>)</span></span>
<pre><span style="font-size: small"><span style="font-size: medium"><strong> </strong></span></span><span style="font-size: small"><span style="font-size: medium"><strong>-EventSource &lt;Object&gt;</strong></span></span></pre>
<span style="font-size: small"><span style="font-size: medium">=&gt; <em><strong>where &lt;Object&gt; default = “All”</strong>, if you don't specify this parameter, the script will search for all Event Sources, and you can also specify a source name like <strong>-EventSource Outlook</strong> (no need for the quotes) or several source names like <strong>-EventSource Outlook, Disk</strong> … </em></span></span><span style="font-size: medium"><em><span style="font-size: small"><span style="font-size: medium"><strong> </strong></span></span></em></span>
<pre><span style="font-size: medium"><span style="font-size: small"><span style="font-size: medium"><strong>-EventLevel &lt;Object&gt;</strong></span></span></span></pre>
<span style="font-size: small"><span style="font-size: medium">=&gt; <em><strong>where &lt;Object&gt; default = “All”</strong>, if you don't specify this parameter, the script will search all Levels (Info, Warning, Errors, Critical, …)</em></span></span>

<span style="font-size: small"><span style="font-size: medium"><em>You can specify an event level like <strong>-EventLevel Error</strong> or several levels like <strong>-EventLevel Warning, Error</strong> … </em></span></span>

<span style="font-size: small"><em><span style="font-size: medium">There is a defined set of event level you can use, you can cycle through the valid values for this parameter by hitting “<strong>TAB</strong>” after you specify the <strong>–EventLevel</strong> parameter. </span></em></span>

<span style="font-size: small"><em><span style="font-size: medium">Possible values are: "All" (default),"Information","Warning","Error","Critical", "Verbose"…</span></em></span>
<pre><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: medium"> </span></span></strong></span></span></span></strong></span></span></span></strong></span></span></span></strong></span></span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: small"><span style="font-size: small"><strong><span><span style="font-size: medium">-NumberOfLastEventsToGet &lt;Int32&gt;</span></span></strong><strong><span></span></strong></span></span></span></strong></span></span></span></strong></span></span></span></strong></span></span></pre>
<span style="font-size: small"><span style="font-size: medium">=&gt; <em><strong>where &lt;Int32&gt; default = 30</strong></em>, and this will dump the 30 or less (if the event log has less, it will dump all of these)</span></span>
<pre><span style="font-size: small"><strong><span><span style="font-size: medium"> </span></span></strong></span><span style="font-size: small"><strong><span><span style="font-size: medium">-ExportToFile [&lt;SwitchParameter&gt;]</span></span></strong><strong><span></span></strong></span></pre>
<span style="font-size: small"><span style="font-size: medium">=&gt; if you don’t specify <strong>-ExportToFile</strong> the script will just dump the events into screen. If you specify it, it will dump the event into a CSV file for easy parsing in Excel !</span></span>

<span style="font-size: small"><span style="font-size: medium">To check the full help of the script, type </span></span>
<pre>get-help .\Get-EventsFromEventLogs.ps1 -Full</pre>
<span style="font-size: small"><span style="font-size: medium">To check the examples only type:</span></span>
<pre>get-help .\Get-EventsFromEventLogs.ps1 -Examples</pre>
<strong> </strong>

<span style="font-size: medium"><a target="_blank" href="https://gallery.technet.microsoft.com/View-or-Export-To-CSV-62ebd49c" rel="noopener"><strong><span>Click here to get to the Download Link on TechNet Gallery</span></strong></a></span>

<span style="font-size: small"><span style="font-size: medium"> </span></span>

<span style="font-size: small"><span style="font-size: medium">Here is the dump of the Examples:</span></span>

&nbsp;
<pre>NAME
 C:\Users\SammyKrosoft\documents\Github\Powershell\Get-EventsFromEventLog\Get-EventsFromEventLogs.ps1
 
SYNOPSIS
 Searches and Get specific events from any computer, local or remote, or from a computer list.
 
 
 -------------------------- EXAMPLE 1 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1
 
 Launching the script without options will :
 - Ask you which event(s) you wish to search for (separated by commas if you want multiple event IDs to search)
 - Search the local computer
 - Search the Application and System logs
 - Get 30 events of the type specified
 
  
 
 -------------------------- EXAMPLE 2 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -Computers MyServers -EventLevel Error
 
 This will collect the Error events (the last 30 errors by default) from the computer named MyServers. 
 It won't store it into a file as we didn't call the "-ExportToFile" parameter, just dump into the screen
 to have an idea if your server is okay or if it's full of errors
 
  
 
 -------------------------- EXAMPLE 3 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -Computers SRV-EX-01,SRV-EX-02,SRV-EX-03 -EventLevel Error -ExportToFile
 
 This will collect the Warning, Error, Critical events on computers SRV-EX-01, 02 and 03. The results
 will be dumped into a file labelled GetEventsFromEventLogs-Date-time.csv as we specified the
 ExportToFile parameter.
 Note that the computers list can come from a txt file as well (see next example)
 
  
 
 -------------------------- EXAMPLE 4 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventsLogs.ps1 -Computers $(Get-Content .\ServersList.txt) -EventLevel Error,Critical -ExportToFile
 
 This will collect Error and Critical events on computers list defined in the "ServersList.txt" file on the current 
 directory from where you launched the script (.\ refers to the current user directory, NOT the directory where the
 script is) and store it into a file.
  
 
 
 -------------------------- EXAMPLE 5 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -NumberOfLastEventsToGet 10 -EventID 916,105 -ExportToFile
 
 - Search for the 10 last events (-NumberOfLastEventsToGet 10) 
 - Search for event IDs 916 and 105
 - As no Event Log name (Application, System, Security, etc...) were specified, 
 the script will look inside the Application AND System logs by default.
 - We asked the script to look for Event IDs 916 and 105 (-EventID 916, 105)
 
 The exported file will be named GetEventsFromEventLogs_916-105_2018-04-13-10-01-55.csv
 as I ran the script on 13th April 2018 at 10h01 and 55 seconds in the morning.
  
 
 
 -------------------------- EXAMPLE 6 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -NumberOfLastEventsToGet 30 -EventID 26 -EventLogName Application
 
 - Search for the last 30 events (-NumberOfLastEventsToGet 30)
 - Search for Event ID 26 only
 - Search in the Application Log only
 - We don't output any file, just print the results on the screen
 
  
 
 -------------------------- EXAMPLE 7 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -EventSource "Outlook"
 
 - Search all events generated by the "Outlook" application (all Event IDs, all Level (Info, Warning, etc...))
 - Search in Application and System (because I didn't specify which event log)
 - Search the last 30 events of type "Outlook" - if there are less, it will just print less
 - We don't output any file because I didn't specify the -ExportToFile parameter
 
 MachineName LogName TimeCreated LevelDisplayName Id Message
 ----------- ------- ----------- ---------------- -- -------
 12345678901 Application 4/13/2018 11:57:06 AM Information 63 La demande de service web Exchange GetAppManifestssuccÃ¨de Ã .&lt;/0w&gt;
 12345678901 Application 4/13/2018 7:57:00 AM Information 63 La demande de service web Exchange GetAppManifestssuccÃ¨de Ã .&lt;/0w&gt;
 12345678901 Application 4/13/2018 7:56:59 AM Information 63 Outlook a dÃ©tectÃ© une notification de modification pour vos applications et va t...
 12345678901 Application 4/13/2018 7:56:55 AM Information 45 Outlook a chargÃ© le(s) complÃ©ment(s) suivant(s) :...
  
 
 
 -------------------------- EXAMPLE 8 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -EventSource "disk","Outlook" -EventLevel Warning -NumberOfLastEventsToGet 1000
 
 - Search all events which source are "Disk" and "Outlook"
 - Search only "Warning" events of the above defined sources
 - All Event IDs of these (because I didn't specify any ID to filter)
 - Get the 1000 last events of the above criteria
 - didn't specify the -ExportToFile so will just display to screen
  
 
 
 -------------------------- EXAMPLE 9 --------------------------
 
 PS C:\&gt;.\Get-EventsFromEventLogs.ps1 -EventSource "disk" -NumberOfLastEventsToGet 1000 -EventLevel Critical,Warning,Error -ExportToFile
 
 - Search all events about the "disk"
 - Search only Critical, Warning and Error events
 - Search the 1000 last events about the above criteria
 - Export into a file (like GetEventsFromEventLogs_None_2018-04-14-04-34-27.csv)</pre>
&nbsp;

&nbsp;

<span style="font-size: medium"><a target="_blank" href="https://gallery.technet.microsoft.com/View-or-Export-To-CSV-62ebd49c" rel="noopener"><strong>Download link (same as above)</strong></a></span>

<span style="font-size: medium">Try it and let me know your thoughts !</span>

<span style="font-size: medium">Cheers</span>

<span style="font-size: small"><span style="font-size: medium">Sam</span></span>]]></content:encoded>
    </item>
  </channel>
</rss>