« Exchange pour de vrai » : différence entre les versions

De Justine's wiki
Aller à la navigation Aller à la recherche
(Page créée avec « = Introduction = Cette page est destinée à contenir de vraies informations pratiques concernant les serveurs Exchange et comment les administrer, notamment en PowerShe... »)
 
Aucun résumé des modifications
 
(14 versions intermédiaires par la même utilisatrice non affichées)
Ligne 1 : Ligne 1 :
[[Category:windows]]
https://sourcedaddy.com/windows-7/troubleshooting-exchange-server.html


= Introduction =
= Introduction =
Ligne 6 : Ligne 8 :
Microsoft Exchange Server est un groupware (logiciel de groupe de travail) pour serveur de messagerie électronique créé par Microsoft. Il existe aussi en SaaS avec Office365.
Microsoft Exchange Server est un groupware (logiciel de groupe de travail) pour serveur de messagerie électronique créé par Microsoft. Il existe aussi en SaaS avec Office365.


= Commandes PowerShell =
= Console ECP =


Sources :
La console ecp est accessible via https://<adresse>/ecp.


*https://www.msb365.blog/?p=1388
Elle permet de gérer la messagerie depuis une GUI.


==== 1 GET-MIGRATIONUSER ====
= Calendriers =


&nbsp;
Les calendriers (collectifs) sont liés à une adresse de type *utilisateur* (et non pas ressource, ce serait si logique). Un calendrier donne une adresse, à laquelle les gens sont sensés pouvoir accéder par OWA > ouvrir une autre boîte mail.


Migrating mailboxes from one Exchange to another, or even to Exchange Online is no rocket science anymore. How to do that, we can find in many articles in the Tech Blogs all over the world. I want to write here about how to check the status of the migration. All we need to do is to connect by PowerShell to the right endpoint. In this example, I am connecting to the Exchange Online by using the following command:
Ci-dessous, une commande pour donner des droits sur ce genre de calendrier à quelqu'un (testé mais pas validé...):
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3ace071253230" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3ace071253230-1">1</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3ace071253230-2">2</div> <div class="crayon-num" data-line="crayon-5ca464a0d3ace071253230-3">3</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3ace071253230-1"><span class="crayon-sy">$</span><span class="crayon-v">UserCredential</span><span class="crayon-h"></span><span class="crayon-o">=</span><span class="crayon-h"></span><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-i">Credential</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3ace071253230-2"><span class="crayon-sy">$</span><span class="crayon-v">Session</span><span class="crayon-h"></span><span class="crayon-o">=</span><span class="crayon-h"></span><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">PSSession</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">ConfigurationName </span><span class="crayon-v">Microsoft</span><span class="crayon-sy">.</span><span class="crayon-v">Exchange</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">ConnectionUri </span><span class="crayon-v">https</span><span class="crayon-o">:</span><span class="crayon-c">//outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection</span></div> <div class="crayon-line" id="crayon-5ca464a0d3ace071253230-3"><span class="crayon-v">Import</span><span class="crayon-o">-</span><span class="crayon-i">PSSession</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">Session</span></div> </div>
|}
</div> </div>
&nbsp;


After I am connected to my endpoint, I can check the status of the migration batch with the following command:
<syntaxhighlight lang="pshell">
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3ad8637173528" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-MigrationUser -BatchId StagedBatch1 | Get-MigrationUserStatistics</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
PS Z:\> Add-MailboxFolderPermission -Identity "calendrier" -User "autre.user" -AccessRights "Contributor"  
{| class="crayon-table" style=""
FolderName          User                AccessRights
|- class="crayon-row"
----------           ----                 ------------
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3ad8637173528-1">1</div> </div>
Haut de la banque... Anaise Leroy        {Contributor}
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3ad8637173528-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MigrationUser</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">BatchId </span><span class="crayon-v">StagedBatch1</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MigrationUserStatistics</span></div> </div>
|}
</div> </div>
As we can see in the screen shot, we get the status of any move request&nbsp;within our migration batch.


https://msb365.abstergo.ch/wp-content/uploads/2018/02/1-7.png


By knowing this command and understanding PowerShell, we are free to modify this command as well. Here´s another example:
PS Z:\> Get-MailboxFolderPermission -identity orientation-calendrier | fl
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3ada450874259" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-MigrationUser -BatchId BATCH | where {$_.Status -ne 'Completed'} | Get-MigrationUserStatistics</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
</syntaxhighlight>
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3ada450874259-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3ada450874259-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MigrationUser</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">BatchId </span><span class="crayon-v">BATCH</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-e">where</span><span class="crayon-h"></span><span class="crayon-sy">{</span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">Status</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">ne</span><span class="crayon-h"></span><span class="crayon-s">'Completed'</span><span class="crayon-sy">}</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MigrationUserStatistics</span></div> </div>
|}
</div> </div>
In this example, only those mailboxes will be shown, which don’t have the status “completed”. This is very helpful&nbsp;to keep an easy overview of huge migration batches .


----


&nbsp;
= Commandes PowerShell =
 
==== 2 GET-MESSAGETRACKINGLOG ====
 
By working as an Exchange administrator or in 2<sup>nd</sup> level support, one of the main tasks is to track messages. Microsoft has created the Exchange Toolbox for this.
 
https://msb365.abstergo.ch/wp-content/uploads/2018/02/2-5.png
 
If we start it, we can see a collection of tools, which help us to investigate some issues.
 
https://msb365.abstergo.ch/wp-content/uploads/2018/02/3-5.png
 
However, to check the Tracking Log there is a faster and easier way to do it.
 
We simply can use the following PowerShell command for that:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3adc199696364" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-MessageTrackingLog -Start "02/26/2018 08:23:00" -End "02/28/2018 17:00:00" -Recipients $recipientSMTP -Server $ExchServer</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3adc199696364-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3adc199696364-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MessageTrackingLog</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Start</span><span class="crayon-h"></span><span class="crayon-s">"02/26/2018 08:23:00"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-st">End</span><span class="crayon-h"></span><span class="crayon-s">"02/28/2018 17:00:00"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Recipients</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">recipientSMTP</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Server</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">ExchServer</span></div> </div>
|}
</div> </div>
In my example, I was searching for all mails sent during a time range on a specific exchange server, which have been sent to a specific recipient:
 
https://msb365.abstergo.ch/wp-content/uploads/2018/02/4-10.png
 
However, there are also some other options for searching. Instead of searching by recipient, we are also able to search by:
 
*MessageSubject
*Reference
*Sender
*InternalMessageId
*MessageId
 
&nbsp;
 
In the most cases we search for sender, recipient or message subject. You can see the output in the example above, with which we can work…
 
Another option is to create a Grid-View like I described in my&nbsp;[https://msb365.abstergo.ch/?p=1202 other article] about PowerShell commands.
 
Now, I want to show you a different option for creating nice reports:
 
If we use the following command:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3ae6329577151" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-MessageTrackingLog -Start "02/26/2018 09:00:00" -End "02/27/2018 09:10:00" | ConvertTo-Html &gt; "C:\_DrPe\message-track.html"</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3ae6329577151-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3ae6329577151-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">MessageTrackingLog</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Start</span><span class="crayon-h"></span><span class="crayon-s">"02/26/2018 09:00:00"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-st">End</span><span class="crayon-h"></span><span class="crayon-s">"02/27/2018 09:10:00"</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-v">ConvertTo</span><span class="crayon-o">-</span><span class="crayon-v">Html</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-s">"C:\_DrPe\message-track.html"</span></div> </div>
|}
</div> </div>
We will get a report in form of an HTML file, which looks like the one below.
 
https://msb365.abstergo.ch/wp-content/uploads/2018/02/5-4.png
 
----
 
&nbsp;
 
==== 3 SET-CALENDERPROCESSING ====
 
The next cmdlet works on Exchange server 2016 an on Exchange online, we can use the cmdlet to modify calendar processing options for resource mailboxes, which include the calendar attendant, resource booking assistant, and the calendar configuration. With this cmdlet we are able to do many things, let’s go for some examples…
 
There is a company which has, let’s say, 10 meeting rooms. 9 of them are free to book for all employees, but one is only available for a dedicated group in the company, e.g the HR.
 
So now we need to prevent all users except the HR to be able to book this meeting room.
 
To do this, we simply run the following command:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3aed720062490" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-CalendarProcessing "MeetingRoom1" -BookInPolicy "User1","User2","User3","User4"</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3aed720062490-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3aed720062490-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-i">CalendarProcessing</span><span class="crayon-h"></span><span class="crayon-s">"MeetingRoom1"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">BookInPolicy</span><span class="crayon-h"></span><span class="crayon-s">"User1"</span><span class="crayon-sy">,</span><span class="crayon-s">"User2"</span><span class="crayon-sy">,</span><span class="crayon-s">"User3"</span><span class="crayon-sy">,</span><span class="crayon-s">"User4"</span></div> </div>
|}
</div> </div>
Now we are sure, that only these users are able to make bookings for the specified meeting room.
 
Another example automates the processing of calendar requests to the resource mailbox SBB23:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3af0053204911" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-CalendarProcessing -Identity "SBB23" -AutomateProcessing AutoAccept -DeleteComments $true -AddOrganizerToSubject $true -AllowConflicts $false</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3af0053204911-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3af0053204911-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-v">CalendarProcessing</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Identity</span><span class="crayon-h"></span><span class="crayon-s">"SBB23"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">AutomateProcessing </span><span class="crayon-v">AutoAccept</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">DeleteComments</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-t">true</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">AddOrganizerToSubject</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-t">true</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">AllowConflicts</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-t">false</span></div> </div>
|}
</div> </div>
With the Set-CalendarProcessing cmdlet we are also able to disable the automatic processing. Here´s an example for a company car with the license plate GR123321:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3af2016039751" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-CalendarProcessing -Identity "GR123321" -AutomateProcessing None</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3af2016039751-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3af2016039751-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-v">CalendarProcessing</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Identity</span><span class="crayon-h"></span><span class="crayon-s">"GR123321"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">AutomateProcessing </span><span class="crayon-v">None</span></div> </div>
|}
</div> </div>
&nbsp;
 
----
 
&nbsp;
 
==== 4 SET-MAILBOXAUTOREPLYCONFIGURATION ====
 
Ready for number 4?&nbsp;This cmdlet, is again one for all the Exchange admins in the field. Sometimes it happens that users go to vacation and they forget to set the Out of Office Notification. Another example is, when a user is sick for a while and there is also a need to set the Out of Office notification.
 
There are different ways how to do that, but by some easy ways it could be a problem with the legal. To be fast to make it and to stay on the legal side, I prefer to user PowerShell for this task.
 
In my example the user Desmond Miles went to vacation and he forgot to activate his Out of Office notification. So, to be sure that people who are writing him will receive the right notification, I use the following command:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3af3019578533" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-MailboxAutoReplyConfiguration -Identity "Desmond Miles" -AutoReplyState Enabled ` -InternalMessage "I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters." ` -ExternalMessage "I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance."</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3af3019578533-1">1</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3af3019578533-2">2</div> <div class="crayon-num" data-line="crayon-5ca464a0d3af3019578533-3">3</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3af3019578533-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-v">MailboxAutoReplyConfiguration</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Identity</span><span class="crayon-h"></span><span class="crayon-s">"Desmond Miles"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">AutoReplyState </span><span class="crayon-i">Enabled</span><span class="crayon-h"></span><span class="crayon-sy">`</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3af3019578533-2"><span class="crayon-o">-</span><span class="crayon-i">InternalMessage</span><span class="crayon-h"></span><span class="crayon-s">"I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters."</span><span class="crayon-h"></span><span class="crayon-sy">`</span></div> <div class="crayon-line" id="crayon-5ca464a0d3af3019578533-3"><span class="crayon-o">-</span><span class="crayon-i">ExternalMessage</span><span class="crayon-h"></span><span class="crayon-s">"I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance."</span></div> </div>
|}
</div> </div>
We can also schedule the time period from when till when we want to have the notification activated. Here, the way how this works:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3af5039685122" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-MailboxAutoReplyConfiguration -Identity "ALIAS" -AutoReplyState Scheduled –StartTime “02/28/2018 07:00:00” –EndTime 03/18/2018 17:00:00 ` -InternalMessage "I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters." ` -ExternalMessage "I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance."</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3af5039685122-1">1</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3af5039685122-2">2</div> <div class="crayon-num" data-line="crayon-5ca464a0d3af5039685122-3">3</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3af5039685122-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-v">MailboxAutoReplyConfiguration</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Identity</span><span class="crayon-h"></span><span class="crayon-s">"ALIAS"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">AutoReplyState </span><span class="crayon-i">Scheduled</span><span class="crayon-h"></span>–<span class="crayon-i">StartTime</span><span class="crayon-h"></span>“<span class="crayon-cn">02</span><span class="crayon-o">/</span><span class="crayon-cn">28</span><span class="crayon-o">/</span><span class="crayon-cn">2018</span><span class="crayon-h"></span><span class="crayon-cn">07</span><span class="crayon-o">:</span><span class="crayon-cn">00</span><span class="crayon-o">:</span><span class="crayon-cn">00</span>”<span class="crayon-h"></span>–<span class="crayon-i">EndTime</span><span class="crayon-h"></span><span class="crayon-cn">03</span><span class="crayon-o">/</span><span class="crayon-cn">18</span><span class="crayon-o">/</span><span class="crayon-cn">2018</span><span class="crayon-h"></span><span class="crayon-cn">17</span><span class="crayon-o">:</span><span class="crayon-cn">00</span><span class="crayon-o">:</span><span class="crayon-cn">00</span><span class="crayon-h"></span><span class="crayon-sy">`</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3af5039685122-2"><span class="crayon-o">-</span><span class="crayon-i">InternalMessage</span><span class="crayon-h"></span><span class="crayon-s">"I'm currently on leave until 23th April. Please contact Ezio Auditore on x72023 for urgent matters."</span><span class="crayon-h"></span><span class="crayon-sy">`</span></div> <div class="crayon-line" id="crayon-5ca464a0d3af5039685122-3"><span class="crayon-o">-</span><span class="crayon-i">ExternalMessage</span><span class="crayon-h"></span><span class="crayon-s">"I'm currently on leave. Please contact our Administration Department on +41 12 345 67 89 for further assistance."</span></div> </div>
|}
</div> </div>
&nbsp;
 
----
 
&nbsp;
 
==== 5 NEW-MAILBOXEXPORTREQUEST ====
 
Here we go, halftime with the number 5…
 
The New-MailboxExportRequest cmdlet helps us to create a PST File from a user mailbox without the compulsion to login to the users account. This helps us, like the previous cmdlet, not to get in trouble with the legal. This command only works with on-premise Exchange servers, if you need to make a PST export from an Exchange Online mailbox, you can check [https://msb365.abstergo.ch/?p=901 my other article here].
 
'''Note:''' This cmdlet is available only for the Mailbox Import Export role and by default, that role isn’t assigned to a role group. To use this cmdlet, you need to add the Mailbox Import Export role to a role group (for example, to the Organization Management role group). Another requirement for exporting to a file share ist to grant the group ”&nbsp;Exchange Trusted Subsystem” read/write permissions to the target share.
 
In the first example we are going to create a PST export of the user mailbox “User01” to a file share server. To do that, we can run the following command:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3af6974596264" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-MailboxExportRequest -Mailbox User01 -FilePath ‘\\SERVER01\PSTFileShare\User01_Recovered.pst’</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3af6974596264-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3af6974596264-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">MailboxExportRequest</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">Mailbox </span><span class="crayon-v">User01</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">FilePath</span><span class="crayon-h"></span>‘<span class="crayon-sy">\</span><span class="crayon-sy">\</span><span class="crayon-v">SERVER01</span><span class="crayon-sy">\</span><span class="crayon-v">PSTFileShare</span><span class="crayon-sy">\</span><span class="crayon-v">User01_Recovered</span><span class="crayon-sy">.</span><span class="crayon-i">pst</span>’</div> </div>
|}
</div> </div>
How about an archive? The command is almost the same one! We only need to add the option “IsArchive”
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3afd646437256" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-MailboxExportRequest -Mailbox User01 -FilePath ‘\\SERVER01\PSTFileShare\User01Archive_Recovered.pst’ -IsArchive</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3afd646437256-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3afd646437256-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">MailboxExportRequest</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">Mailbox </span><span class="crayon-v">User01</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">FilePath</span><span class="crayon-h"></span>‘<span class="crayon-sy">\</span><span class="crayon-sy">\</span><span class="crayon-v">SERVER01</span><span class="crayon-sy">\</span><span class="crayon-v">PSTFileShare</span><span class="crayon-sy">\</span><span class="crayon-v">User01Archive_Recovered</span><span class="crayon-sy">.</span><span class="crayon-i">pst</span>’<span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">IsArchive</span></div> </div>
|}
</div> </div>
Sometimes we don’t want to export the whole mailbox to a PST file. Imagine, we are just interested in messages with the words “company” and “phone”, which have been received before a specific date. For this, we can edit our command in the following way:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3aff947169227" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-MailboxExportRequest -Mailbox User01 -ContentFilter {(body -like "*company*") -and (body -like "*phone*") -and (Received -lt "01/01/2012")} -FilePath ‘\\SERVER01\PSTFileShare\User1_CompanyPhone.pst’</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3aff947169227-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3aff947169227-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-e">MailboxExportRequest</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">Mailbox</span><span class="crayon-h"></span><span class="crayon-e">User01</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">ContentFilter</span><span class="crayon-h"></span><span class="crayon-sy">{</span><span class="crayon-sy">(</span><span class="crayon-v">body</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">like</span><span class="crayon-h"></span><span class="crayon-s">"*company*"</span><span class="crayon-sy">)</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-st">and</span><span class="crayon-h"></span><span class="crayon-sy">(</span><span class="crayon-v">body</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">like</span><span class="crayon-h"></span><span class="crayon-s">"*phone*"</span><span class="crayon-sy">)</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-st">and</span><span class="crayon-h"></span><span class="crayon-sy">(</span><span class="crayon-v">Received</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">lt</span><span class="crayon-h"></span><span class="crayon-s">"01/01/2012"</span><span class="crayon-sy">)</span><span class="crayon-sy">}</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">FilePath</span><span class="crayon-h"></span>‘<span class="crayon-sy">\</span><span class="crayon-sy">\</span><span class="crayon-v">SERVER01</span><span class="crayon-sy">\</span><span class="crayon-v">PSTFileShare</span><span class="crayon-sy">\</span><span class="crayon-v">User1_CompanyPhone</span><span class="crayon-sy">.</span><span class="crayon-i">pst</span>’</div> </div>
|}
</div> </div>
This commands can help us with the preservation of evidence, for example…


At this point, I would like to point out the following: with great power comes great responsibility!!<br/> This is a very powerful command. Be aware of it…
== Boîtes partagées ==


----
<syntaxhighlight lang="pshell">
#Membres d'une BP
Get-Mailbox formation-continue-iae | Get-MailboxPermission | select identity,user,accessrights


&nbsp;
</syntaxhighlight>


==== 6 GET-PARTNERAPPLICATION ====
== Autres ==
Sources:


This command works for Exchange on-premise and for Exchange Online. With this command we are able to configure partner applications such as Microsoft SharePoint to access the resources of our Exchange environment.
*[https://www.msb365.blog/?p=1388 https://www.msb365.blog/?p=1388]


If I want to get access to data in a system, I usually have to log in (authenticate) and I must have obtained the required permissions (authorization). For users, this is a well-known process that you need to log in to the Active Directory first and then log on to the SID and their group memberships, for example, to access file shares that have ACL’s associated permissions added to them. For the Exchange administration with RBAC, users are also used, but then they are granted permissions via roles.
Use the following commands to&nbsp;add or remove an email alias using [https://msdn.microsoft.com/en-us/powershell/mt173057.aspx Powershell] commands:


&nbsp;
To ''check'' current exchange mailbox aliases:
<pre>'''Get-Mailbox mailboxname | select -expand emailaddresses alias'''</pre>


Microsoft describes this function like:
To ''add'' an email alias to an exchange mailbox:
<pre>'''Set-Mailbox mailboxname -EmailAddresses @{Add='alias@somedomain.co.uk'}'''</pre>


When Exchange 2013 receives an access request from a partner application via Exchange Web Services (EWS), it parses the www-authenticateheader of the https request, which contains the access token signed by the calling server using its private key. The auth module validates the access token using the partner application configuration. It then grants access to resources based on the RBAC permissions granted to the application. If the access token is on behalf of a user, the RBAC permissions granted to the user are checked.
To ''delete'' an email alias from an exchange mailbox:


So, here´s an example how this command works for us:
'''Set-Mailbox mailboxname -EmailAddresses @{Remove=’alias@somedomain.co.uk’}'''


If we use the following command:
== Re-lier une boîte dans une configuration avec une boîte liée ==
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b01745705670" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Set-PartnerApplication HRApp -RefreshAuthMetadata</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b01745705670-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b01745705670-1"><span class="crayon-v">Set</span><span class="crayon-o">-</span><span class="crayon-e">PartnerApplication </span><span class="crayon-v">HRApp</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">RefreshAuthMetadata</span></div> </div>
|}
</div> </div>
We are refreshing the auth metadata for the HRApp partner application.


&nbsp;
Dans un contexte avec plusieurs domaines AD, il se peut que les boîtes d'un domaine soient liées au comptes sur un autre domaine. Chaque boite est liée grâce au SID, un identifiant unique qui désigne le compte sur le domaine AD lié. Nous avons donc :
* Un domaine 1 avec un AD.
* Un autre domaine 2, avec des boîtes et avec son propre AD; mais pour une raison X les boites du domaine 2 sont liées au domaine 1.


Another example is, when we want to create a new HRApp partner application called HRApp:
Parfois, certaines boîtes peuvent se retrouver liées au mauvais SID. Voilà comment faire :  
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b02137228601" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-PartnerApplication –Name HRApp –ApplicationIdentifier 00000009-1234-12we-tz12-123654789wef -Realm contoso.com -UseAuthServer $true</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b02137228601-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b02137228601-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-i">PartnerApplication</span><span class="crayon-h"></span>–<span class="crayon-e">Name </span><span class="crayon-i">HRApp</span><span class="crayon-h"></span>–<span class="crayon-i">ApplicationIdentifier</span><span class="crayon-h"></span><span class="crayon-cn">00000009</span><span class="crayon-o">-</span><span class="crayon-cn">1234</span><span class="crayon-o">-</span><span class="crayon-cn">12we</span><span class="crayon-o">-</span><span class="crayon-v">tz12</span><span class="crayon-o">-</span><span class="crayon-cn">123654789wef</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-e">Realm </span><span class="crayon-v">contoso</span><span class="crayon-sy">.</span><span class="crayon-v">com</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">UseAuthServer</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-t">true</span></div> </div>
|}
</div> </div>
The ApplicationIdentifier parameter specifies a unique application identifier for the partner application that uses an authorization server. When specifying a value for the ApplicationIdentifier parameter, you must also use the ''UseAuthServer'' parameter.


&nbsp;
<syntaxhighlight lang="Powershell">
Get-Mailbox xxx@yyy | fl #On récupère les infos
Disable-Mailbox xxx@yyy #On désactive la boîte d'une façon ou d'une autre
Connect-Mailbox -LinkedDomainController "adc.domaine1" -LinkedMasterAccount "domaine1\madametruc" -Alias "truc" -Identity "Josiane Truc" -Database BASE-DB1
</syntaxhighlight>


----
= Troubleshooting =


&nbsp;
== MessageTrackingLog ==
Similaire à un maillog Linux, mais en moins pratique.


==== 7 NEW-ITEM ====
<syntaxhighlight lang="powershell">
Get-MessageTrackingLog -Recipients justine@domaine.fr
Get-MessageTrackingLog  -ResultSize Unlimited | Where-Object {$_.Recipients -like "*sarah.connor*"}
Get-MessageTrackingLog -Start "09/30/2019 08:00:00" -End "09/30/2019 20:00:00" -Sender "luke.skywalker@rebellion.org"
</syntaxhighlight>


Now let’s talk about one we all know (I guess). Sometimes when I am writing a script I want to create a dedicated directory to, for example, dump out files or reports. When I write scripts alone or together with Dominic, I try to make them as universal as possible. Many things can be handled with variables, but sometimes we have to create things, in this case a directory.
On dispose bien entendu des autres logs Windows (voir [[Analyse de logs]]), mais ils ne sont pas pratiques non plus.


To create a directory with PowerShell we simply need one command: New-Item.
== Commandes de test ==


&nbsp;
PowerShell contient de nombreux cmdlets de test, et il serait bête de ne pas s'en servir !


With the New-Item cmdlet we can create different things like directories, files, registry keys, etc.
On peut les voir toutes avec :


Here are some examples how to use it:
<syntaxhighlight lang='powershell'>
#Vérification du statuts des migrations en cours :
                Get-MoveRequest | where status -eq "InProgress" | Get-MoveRequestStatistics


If we want to create a new directory on the C:\ partition for our PowerShell scripts, we can go with this command:
#Vérification des users sur une database particulière :
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b04260884231" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-Item –ItemType Directory –Force –Path c:\DrPe\scripts</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
                Get-Mailbox -database <db_name>
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b04260884231-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b04260884231-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-i">Item</span><span class="crayon-h"></span>–<span class="crayon-e">ItemType </span><span class="crayon-i">Directory</span><span class="crayon-h"></span>–<span class="crayon-i">Force</span><span class="crayon-h"></span>–<span class="crayon-i">Path</span><span class="crayon-h"></span><span class="crayon-v">c</span><span class="crayon-o">:</span><span class="crayon-sy">\</span><span class="crayon-v">DrPe</span><span class="crayon-sy">\</span><span class="crayon-v">scripts</span></div> </div>
|}
</div> </div>
If we want to create a file in this directory, we can use almost the same command, for creating a .txt file we will use:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b0a440483178" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-Item –ItemType File –Path c:\DrPe\scripts\demo.txt</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b0a440483178-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b0a440483178-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-i">Item</span><span class="crayon-h"></span>–<span class="crayon-e">ItemType </span><span class="crayon-i">File</span><span class="crayon-h"></span>–<span class="crayon-i">Path</span><span class="crayon-h"></span><span class="crayon-v">c</span><span class="crayon-o">:</span><span class="crayon-sy">\</span><span class="crayon-v">DrPe</span><span class="crayon-sy">\</span><span class="crayon-v">scripts</span><span class="crayon-sy">\</span><span class="crayon-v">demo</span><span class="crayon-sy">.</span><span class="crayon-v">txt</span></div> </div>
|}
</div> </div>
How about existing files? If we try to create a new file but this file already exists, we will receive the following error message:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b0c079429754" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-Item : The file 'C:\scripts\new_file.txt' already exists.</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b0c079429754-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b0c079429754-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">Item</span><span class="crayon-h"></span><span class="crayon-o">:</span><span class="crayon-h"></span><span class="crayon-e">The </span><span class="crayon-i">file</span><span class="crayon-h"></span><span class="crayon-s">'C:\scripts\new_file.txt'</span><span class="crayon-h"></span><span class="crayon-e">already </span><span class="crayon-v">exists</span><span class="crayon-sy">.</span></div> </div>
|}
</div> </div>
However, if we want to overwrite the existing File, we have the option –''Force'' to overwrite the default behavior. Then the command will look like this:
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b0e723924024" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-Item –ItemType File –Path c:\DrPe\scripts\demo.txt –Force</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b0e723924024-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b0e723924024-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-i">Item</span><span class="crayon-h"></span>–<span class="crayon-e">ItemType </span><span class="crayon-i">File</span><span class="crayon-h"></span>–<span class="crayon-i">Path</span><span class="crayon-h"></span><span class="crayon-v">c</span><span class="crayon-o">:</span><span class="crayon-sy">\</span><span class="crayon-v">DrPe</span><span class="crayon-sy">\</span><span class="crayon-v">scripts</span><span class="crayon-sy">\</span><span class="crayon-v">demo</span><span class="crayon-sy">.</span><span class="crayon-i">txt</span><span class="crayon-h"></span>–<span class="crayon-v">Force</span></div> </div>
|}
</div> </div>
&nbsp;


----
#Récupération des noms de databases :
                Get-MailboxDatabase


&nbsp;
#Récupération des données Mailbox pour un utilisateur :
                Get-Mailbox <user>


==== 8 NEW-MSOLUSER ====
#Récupération des données statistiques d’une mailbox :
                Get-mailbox <user> | get-mailboxstatistics


Let’s talk abit about the Office 365 cloud now. The next command is more known by using its bro ''Get-MsolUser''.
#Pour obtenir le maximum d’info, rajouter en fin de ligne : | fl
</syntaxhighlight>


I want to show you now, how to create new users in the Azure Active Directory. After we have made a successful login to the Azure AD throughPowerShell and successfully downloaded the right PowerShell module before, we can use the command New-MsolUser to create new users.


Now,I want to show you some examples, how we can do that…
== Commandes de suivi des migrations ==


If we need to create one new user, we can use the following command:
<syntaxhighlight lang="powershell">
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b0f230388005" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0; opacity: 0;  overflow: hidden" wrap="soft">New-MsolUser -DisplayName &lt;DisplayName&gt; -FirstName &lt;FirstName&gt; -LastName &lt;LastName&gt; -UserPrincipalName &lt;Account&gt; -UsageLocation &lt;CountryCode&gt; -LicenseAssignment &lt;AccountSkuID&gt; [-Password &lt;Password&gt;]</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
#Vérification du statuts des migrations en cours :
{| class="crayon-table" style=""
  Get-MoveRequest | where status -eq "InProgress" | Get-MoveRequestStatistics
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b0f230388005-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b0f230388005-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">MsolUser</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">DisplayName</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">DisplayName</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">FirstName</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">FirstName</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">LastName</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">LastName</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">UserPrincipalName</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">Account</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">UsageLocation</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">CountryCode</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">LicenseAssignment</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">AccountSkuID</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-sy">[</span><span class="crayon-o">-</span><span class="crayon-v">Password</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-v">Password</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-sy">]</span></div> </div>
|}
</div> </div>
This is easy going, but to create a bulk of new user accounts there must be a easyier way… Yes, there is one!


&nbsp;
#Vérification des users sur une database particulière :
Get-Mailbox -database <db_name>


First we need to create a CSV file. This can look like this:
#Récupération des noms de databases :
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b10263969185" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">UserPrincipalName,FirstName,LastName,DisplayName,UsageLocation,AccountSkuId ClaudeL@contoso.onmicrosoft.com,Claude,Loiselle,Claude Loiselle,US,contoso:ENTERPRISEPACK LynneB@contoso.onmicrosoft.com,Lynne,Baxter,Lynne Baxter,US,contoso:ENTERPRISEPACK ShawnM@contoso.onmicrosoft.com,Shawn,Melendez,Shawn Melendez,US,contoso:ENTERPRISEPACK</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
Get-MailboxDatabase
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b10263969185-1">1</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b10263969185-2">2</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b10263969185-3">3</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b10263969185-4">4</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b10263969185-1"><span class="crayon-v">UserPrincipalName</span><span class="crayon-sy">,</span><span class="crayon-v">FirstName</span><span class="crayon-sy">,</span><span class="crayon-v">LastName</span><span class="crayon-sy">,</span><span class="crayon-v">DisplayName</span><span class="crayon-sy">,</span><span class="crayon-v">UsageLocation</span><span class="crayon-sy">,</span><span class="crayon-e">AccountSkuId</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b10263969185-2"><span class="crayon-v">ClaudeL</span><span class="crayon-sy">@</span><span class="crayon-v">contoso</span><span class="crayon-sy">.</span><span class="crayon-v">onmicrosoft</span><span class="crayon-sy">.</span><span class="crayon-v">com</span><span class="crayon-sy">,</span><span class="crayon-v">Claude</span><span class="crayon-sy">,</span><span class="crayon-v">Loiselle</span><span class="crayon-sy">,</span><span class="crayon-e">Claude </span><span class="crayon-v">Loiselle</span><span class="crayon-sy">,</span><span class="crayon-v">US</span><span class="crayon-sy">,</span><span class="crayon-v">contoso</span><span class="crayon-o">:</span><span class="crayon-e">ENTERPRISEPACK</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b10263969185-3"><span class="crayon-v">LynneB</span><span class="crayon-sy">@</span><span class="crayon-v">contoso</span><span class="crayon-sy">.</span><span class="crayon-v">onmicrosoft</span><span class="crayon-sy">.</span><span class="crayon-v">com</span><span class="crayon-sy">,</span><span class="crayon-v">Lynne</span><span class="crayon-sy">,</span><span class="crayon-v">Baxter</span><span class="crayon-sy">,</span><span class="crayon-e">Lynne </span><span class="crayon-v">Baxter</span><span class="crayon-sy">,</span><span class="crayon-v">US</span><span class="crayon-sy">,</span><span class="crayon-v">contoso</span><span class="crayon-o">:</span><span class="crayon-e">ENTERPRISEPACK</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b10263969185-4"><span class="crayon-v">ShawnM</span><span class="crayon-sy">@</span><span class="crayon-v">contoso</span><span class="crayon-sy">.</span><span class="crayon-v">onmicrosoft</span><span class="crayon-sy">.</span><span class="crayon-v">com</span><span class="crayon-sy">,</span><span class="crayon-v">Shawn</span><span class="crayon-sy">,</span><span class="crayon-v">Melendez</span><span class="crayon-sy">,</span><span class="crayon-e">Shawn </span><span class="crayon-v">Melendez</span><span class="crayon-sy">,</span><span class="crayon-v">US</span><span class="crayon-sy">,</span><span class="crayon-v">contoso</span><span class="crayon-o">:</span><span class="crayon-v">ENTERPRISEPACK</span></div> </div>
|}
</div> </div>
&nbsp;


After we have created this file, we can run the following command:
#Récupération des données Mailbox pour un utilisateur :
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b12347628625" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Import-Csv -Path &lt;Input CSV File Path and Name&gt; | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId [-Password $_.Password]} | Export-Csv -Path &lt;Output CSV File Path and Name&gt;</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
Get-Mailbox <user>
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b12347628625-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b12347628625-1"><span class="crayon-v">Import</span><span class="crayon-o">-</span><span class="crayon-v">Csv</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">Path</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-e">Input </span><span class="crayon-e">CSV </span><span class="crayon-e">File </span><span class="crayon-e">Path </span><span class="crayon-st">and</span><span class="crayon-h"></span><span class="crayon-v">Name</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-st">foreach</span><span class="crayon-h"></span><span class="crayon-sy">{</span><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">MsolUser</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">DisplayName</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">DisplayName</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">FirstName</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">FirstName</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">LastName</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">LastName</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">UserPrincipalName</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">UserPrincipalName</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">UsageLocation</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">UsageLocation</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">LicenseAssignment</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-i">AccountSkuId</span><span class="crayon-h"></span><span class="crayon-sy">[</span><span class="crayon-o">-</span><span class="crayon-i">Password</span><span class="crayon-h"></span><span class="crayon-sy">$</span><span class="crayon-v">_</span><span class="crayon-sy">.</span><span class="crayon-v">Password</span><span class="crayon-sy">]</span><span class="crayon-sy">}</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-v">Export</span><span class="crayon-o">-</span><span class="crayon-v">Csv</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-v">Path</span><span class="crayon-h"></span><span class="crayon-o">&</span><span class="crayon-v">lt</span><span class="crayon-sy">;</span><span class="crayon-e">Output </span><span class="crayon-e">CSV </span><span class="crayon-e">File </span><span class="crayon-e">Path </span><span class="crayon-st">and</span><span class="crayon-h"></span><span class="crayon-v">Name</span><span class="crayon-o">&</span><span class="crayon-v">gt</span><span class="crayon-sy">;</span></div> </div>
|}
</div> </div>
Now, PowerShell is doing magic things, and all users from our CSV file will be created.


https://s.w.org/images/core/emoji/11.2.0/svg/1f642.svg
#Récupération des données statistiques d’une mailbox :
Get-mailbox <user> | get-mailboxstatistics


&nbsp;
#Pour obtenir le maximum d’info, rajouter en fin de ligne : | fl
</syntaxhighlight>


With the New-MsolUser cmdlet we can also create new users and assign a license straight away:
== Convertir une boite partagée en boite normale ==
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b15435401930" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-MsolUser -UserPrincipalName "Desmond.Miles@contoso.com" -DisplayName " Desmond Miles " -FirstName "Desmond" -LastName "Miles" -UsageLocation "CH" -LicenseAssignment "Contoso:BPOS_Standard"</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b15435401930-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b15435401930-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">MsolUser</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">UserPrincipalName</span><span class="crayon-h"></span><span class="crayon-s">"Desmond.Miles@contoso.com"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">DisplayName</span><span class="crayon-h"></span><span class="crayon-s">" Desmond Miles "</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">FirstName</span><span class="crayon-h"></span><span class="crayon-s">"Desmond"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">LastName</span><span class="crayon-h"></span><span class="crayon-s">"Miles"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">UsageLocation</span><span class="crayon-h"></span><span class="crayon-s">"CH"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">LicenseAssignment</span><span class="crayon-h"></span><span class="crayon-s">"Contoso:BPOS_Standard"</span></div> </div>
|}
</div> </div>
&nbsp;


There are also a bulk of optional parameters:
Ici, je part de la boîte partagée "morpheus".
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b1e509262334" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">-AlternativeEmailAddresses # Specifies alternative mail address for the user -AlternativeMobilePhones # Specifies alternative mobile phone numbers fort he user -BlockCredential # Specifies whether the user is not able to log on using their user ID -City # Specifies the city of the user -Country # Specifies the country of the user -Department # Specifies the department of the user -DisplayName # Specifies the display name -Fax # Specifies the fax number of the user -FirstName # Specifies the first name of the user -ForceChangePassword # Indicates that the user is required to change their password at the next time they sign in -ImmutableId # Specifies the immutable ID of the federated identity of the user -LastName # Specifies the last name of the user -LastPasswordChangeTimestamp # Specifies a time when the password was last changed -LicenseAssignment # Specifies an array of licenses to assign the user -LicenseOption # Specifies the options for license assignment. Used to selectively disable individual service plans within a SKU -MobilePhone # Specifies the mobile phone number of the user -Office # Specifies the office of the user -Password # Specifies &nbsp;the new password for the user. -PasswordNeverExpires # Specifies whether the user password expires periodically -PhoneNumber # Specifies the phone number of the user -PostalCode # Specifies the postal code of the user -PreferredDataLocation # Specifies the preferred data location for the user -PreferredLanguage # Specifies the preferred language of the user -SoftDeletionTimestamp # Specifies a time for soft deletion -State # Specifies the state or province where the user is located -StreetAddress # Specifies the street address of the user -StrongAuthenticationRequirements # Specifies an array of strong authentication requirements -StrongPasswordRequired # Specifies whether to require a strong password for the user -StsRefreshTokensValidFrom # Specifies a StsRefreshTokensValidFrom value. -TenantId # Specifies the unique ID of the tenant on which to perform the operation -Title # Specifies the title of the user -UsageLocation # Specifies the location of the user where services are consumed -UserPrincipalName # Specifies the user ID for this user -UserType # Specifies the user type</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-1">1</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-2">2</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-3">3</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-4">4</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-5">5</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-6">6</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-7">7</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-8">8</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-9">9</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-10">10</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-11">11</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-12">12</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-13">13</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-14">14</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-15">15</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-16">16</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-17">17</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-18">18</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-19">19</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-20">20</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-21">21</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-22">22</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-23">23</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-24">24</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-25">25</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-26">26</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-27">27</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-28">28</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-29">29</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-30">30</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-31">31</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-32">32</div> <div class="crayon-num" data-line="crayon-5ca464a0d3b1e509262334-33">33</div> <div class="crayon-num crayon-striped-num" data-line="crayon-5ca464a0d3b1e509262334-34">34</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-1"><span class="crayon-o">-</span><span class="crayon-v">AlternativeEmailAddresses</span><span class="crayon-h"></span><span class="crayon-p"># Specifies alternative mail address for the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-2"><span class="crayon-o">-</span><span class="crayon-v">AlternativeMobilePhones</span><span class="crayon-h"></span><span class="crayon-p"># Specifies alternative mobile phone numbers fort he user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-3"><span class="crayon-o">-</span><span class="crayon-v">BlockCredential</span><span class="crayon-h"></span><span class="crayon-p"># Specifies whether the user is not able to log on using their user ID</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-4"><span class="crayon-o">-</span><span class="crayon-v">City</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the city of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-5"><span class="crayon-o">-</span><span class="crayon-v">Country</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the country of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-6"><span class="crayon-o">-</span><span class="crayon-v">Department</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the department of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-7"><span class="crayon-o">-</span><span class="crayon-v">DisplayName</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the display name</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-8"><span class="crayon-o">-</span><span class="crayon-v">Fax</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the fax number of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-9"><span class="crayon-o">-</span><span class="crayon-v">FirstName</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the first name of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-10"><span class="crayon-o">-</span><span class="crayon-v">ForceChangePassword</span><span class="crayon-h"></span><span class="crayon-p"># Indicates that the user is required to change their password at the next time they sign in</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-11"><span class="crayon-o">-</span><span class="crayon-v">ImmutableId</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the immutable ID of the federated identity of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-12"><span class="crayon-o">-</span><span class="crayon-v">LastName</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the last name of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-13"><span class="crayon-o">-</span><span class="crayon-v">LastPasswordChangeTimestamp</span><span class="crayon-h"></span><span class="crayon-p"># Specifies a time when the password was last changed</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-14"><span class="crayon-o">-</span><span class="crayon-v">LicenseAssignment</span><span class="crayon-h"></span><span class="crayon-p"># Specifies an array of licenses to assign the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-15"><span class="crayon-o">-</span><span class="crayon-v">LicenseOption</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the options for license assignment. Used to selectively disable individual service plans within a SKU</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-16"><span class="crayon-o">-</span><span class="crayon-v">MobilePhone</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the mobile phone number of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-17"><span class="crayon-o">-</span><span class="crayon-v">Office</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the office of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-18"><span class="crayon-o">-</span><span class="crayon-v">Password</span><span class="crayon-h"></span><span class="crayon-p"># Specifies &nbsp;the new password for the user.</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-19"><span class="crayon-o">-</span><span class="crayon-v">PasswordNeverExpires</span><span class="crayon-h"></span><span class="crayon-p"># Specifies whether the user password expires periodically</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-20"><span class="crayon-o">-</span><span class="crayon-v">PhoneNumber</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the phone number of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-21"><span class="crayon-o">-</span><span class="crayon-v">PostalCode</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the postal code of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-22"><span class="crayon-o">-</span><span class="crayon-v">PreferredDataLocation</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the preferred data location for the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-23"><span class="crayon-o">-</span><span class="crayon-v">PreferredLanguage</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the preferred language of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-24"><span class="crayon-o">-</span><span class="crayon-v">SoftDeletionTimestamp</span><span class="crayon-h"></span><span class="crayon-p"># Specifies a time for soft deletion</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-25"><span class="crayon-o">-</span><span class="crayon-v">State</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the state or province where the user is located</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-26"><span class="crayon-o">-</span><span class="crayon-v">StreetAddress</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the street address of the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-27"><span class="crayon-o">-</span><span class="crayon-v">StrongAuthenticationRequirements</span><span class="crayon-h"></span><span class="crayon-p"># Specifies an array of strong authentication requirements</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-28"><span class="crayon-o">-</span><span class="crayon-v">StrongPasswordRequired</span><span class="crayon-h"></span><span class="crayon-p"># Specifies whether to require a strong password for the user</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-29"><span class="crayon-o">-</span><span class="crayon-v">StsRefreshTokensValidFrom</span><span class="crayon-h"></span><span class="crayon-p"># Specifies a StsRefreshTokensValidFrom value.</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-30"><span class="crayon-o">-</span><span class="crayon-v">TenantId</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the unique ID of the tenant on which to perform the operation</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-31"><span class="crayon-o">-</span><span class="crayon-v">Title</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the title of the user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-32"><span class="crayon-o">-</span><span class="crayon-v">UsageLocation</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the location of the user where services are consumed</span></div> <div class="crayon-line" id="crayon-5ca464a0d3b1e509262334-33"><span class="crayon-o">-</span><span class="crayon-v">UserPrincipalName</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the user ID for this user</span></div> <div class="crayon-line crayon-striped-line" id="crayon-5ca464a0d3b1e509262334-34"><span class="crayon-o">-</span><span class="crayon-v">UserType</span><span class="crayon-h"></span><span class="crayon-p"># Specifies the user type</span></div> </div>
|}
</div> </div>
&nbsp;


----
<source lang="powershell">
set-mailbox -id morpheus -type regular
#Une fois cela fait, il faut modifier l'utilisateur AD "morpheus" pour lui donner un mot de passe
</source>


==== 9 GET-HOTFIX ====
= Rôles d'une infra Exchange =


So, the second to last for this article. The Get-Hotfix cmdlet gets hotfixes (also called updates) that have been installed on either the local computer (or on specified remote computers) by Windows Update, Microsoft Update, or Windows Server Update Services; the cmdlet also gets hotfixes or updates that have been installed manually by users.
=== MBX (Mailbox) ===


In the first example we go to check which updates were already installed on my client computer. To do that I simply run the following command:
* Héberge boîtes aux lettres / dossiers publics
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b23439544143" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-Hotfix</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
* Génération OAB / haute disponibilité CCR, SCC, LCR et SCR ou DAG
{| class="crayon-table" style=""
* Ne fait pas le transport de messages (l’envoi / réception d'email échue si pas de serveur transport HUB)
|- class="crayon-row"
* Serveur membre du domaine
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b23439544143-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b23439544143-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">Hotfix</span></div> </div>
|}
</div> </div>
&nbsp;


And as we see in the print screen, there are just a few updates installed on my machine:
=== HUB ===


https://msb365.abstergo.ch/wp-content/uploads/2018/02/6-4.png
* Catégorisation (résolution des destinataires)  / conversion format de mails / routage des messages / règles de transport/ journalisation / taille maximum message envoyé et/ou reçu
* Anti-spam (désactivé par défaut)
* Serveur membre du domaine


In the 2<sup>nd</sup> example I want to check which security hotfixes are installed on a list of computers. To do that we can use the following command:
=== CAS (Client Access Server)===
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b26768788423" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-HotFix -Description "Security*" -ComputerName "Server01", "Server02" -Cred "Server01\admin01"</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b26768788423-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b26768788423-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-v">HotFix</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Description</span><span class="crayon-h"></span><span class="crayon-s">"Security*"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">ComputerName</span><span class="crayon-h"></span><span class="crayon-s">"Server01"</span><span class="crayon-sy">,</span><span class="crayon-h"></span><span class="crayon-s">"Server02"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Cred</span><span class="crayon-h"></span><span class="crayon-s">"Server01\admin01"</span></div> </div>
|}
</div> </div>
&nbsp;


As we see, there are a couple of patches installed:
* Accès boîtes aux lettres via protocole NON MAPI (E[[ActiveSync|AS]], [[Outlook Web Access|OWA]], etc)
* Les services WEB (Auto-Discover) / Distribution OAB
* Serveur membre du domaine
* En Exchange 2010, les clients [[Microsoft Outlook|Outlook]] se connectent sur le serveur CAS pas sur le serveur MAILBOX


https://msb365.abstergo.ch/wp-content/uploads/2018/02/7-2.png
=== EDGE ===


----
* Joue le rôle de relais SMTP
* Remise des messages Internet
* Antispam
* Analyse antivirus (nécessite une solution tierce)
* Serveur NON membre du domaine et dans la [[Zone démilitarisée (informatique)|DMZ]]


&nbsp;
=== UM (Unified Messaging) ===


==== 10 NEW-MANAGEMENTROLEASSIGNMENT ====
* Réponse aux appels
* Réception de télécopie
* Accès à ses mails à distance via Outlook Voice Access (consulter ses messages et son calendrier via module vocal, accepter ou annuler des demandes de rendez-vous)
* Machine membre du domaine
* Non supporté en machine virtuelle
* Nécessite IP-BPX / passerelle VoIP


The (last) command for todays article is working for on-premise Exchange servers and for Exchange Online as well. With the New-ManagementRoleAssignment cmdlet we are able to manage roles for department groups. Maybe it sounds strange, but when I show you some examples, all will be clearer…
== Shadow redundancy (en lien avec les mentions HADISCARD du trackinglog) ==
https://pmeijden.wordpress.com/2011/06/01/shadow-redundancy-explained/


In the first example, I have to assign the Mail Recipient role to the 2<sup>nd</sup>&nbsp;level helpdesk of our company. To do that I run the following command:
How it works
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b28798391524" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-ManagementRoleAssignment –Role ‘Mail Recipients’ –SecurityGroup ‘Level 2 Support’</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b28798391524-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b28798391524-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-i">ManagementRoleAssignment</span><span class="crayon-h"></span>–<span class="crayon-i">Role</span><span class="crayon-h"></span>‘<span class="crayon-e">Mail </span><span class="crayon-i">Recipients</span>’<span class="crayon-h"></span>–<span class="crayon-i">SecurityGroup</span><span class="crayon-h"></span>‘<span class="crayon-i">Level</span><span class="crayon-h"></span><span class="crayon-cn">2</span><span class="crayon-h"></span><span class="crayon-i">Support</span>’</div> </div>
|}
</div> </div>
&nbsp;


We are also able to get some information about management roles. This example assigns the MyVoiceMail role to the “Sales end-users” role assignment policy. First, the IsEndUserRole property on the MyVoiceMail role is verified to be sure it’s set to $true, indicating it’s an end-user role:
The HUB01 will deliver a message that is intended for a user outside the organization to the EDGE01 server. HUB01 detects that the EDGE01 supports shadow redundancy. HUB01 will move the message to the shadow redundancy queue and marks it with EDGE01 as the primary owner. When opening the Queue Viewer you’ll notice that there is one email in the Shadow Redundancy Queue.
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b32590238491" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">Get-ManagementRole "MyVoiceMail" | Format-Table Name, IsEndUserRole</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b32590238491-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b32590238491-1"><span class="crayon-v">Get</span><span class="crayon-o">-</span><span class="crayon-i">ManagementRole</span><span class="crayon-h"></span><span class="crayon-s">"MyVoiceMail"</span><span class="crayon-h"></span><span class="crayon-o">&#124;</span><span class="crayon-h"></span><span class="crayon-v">Format</span><span class="crayon-o">-</span><span class="crayon-e">Table </span><span class="crayon-v">Name</span><span class="crayon-sy">,</span><span class="crayon-h"></span><span class="crayon-v">IsEndUserRole</span></div> </div>
|}
</div> </div>
&nbsp;


After the role has been verified to be an end-user role, the role is assigned to the “Sales end-users” role assignment policy.
clip_image002
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b38140765974" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">New-ManagementRoleAssignment -Role "MyVoiceMail" -Policy "Sales end-users"</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b38140765974-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b38140765974-1"><span class="crayon-r">New</span><span class="crayon-o">-</span><span class="crayon-v">ManagementRoleAssignment</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Role</span><span class="crayon-h"></span><span class="crayon-s">"MyVoiceMail"</span><span class="crayon-h"></span><span class="crayon-o">-</span><span class="crayon-i">Policy</span><span class="crayon-h"></span><span class="crayon-s">"Sales end-users"</span></div> </div>
|}
</div> </div>
&nbsp;


----
Success


&nbsp;
When EDGE01 delivers the message to the internet it updates the discard status of the message indicating that the delivery was successful. HUB01 will check the status of all sent messages (default every 15 minutes) by issuing a XQDISCARD command to EDGE01. EDGE01 will check the discard status and responds with a list of all the messages that are considered to be successfully delivered. HUB01 will delete the messages from the Shadow Redundancy Queue if they are on that list.


==== <span style="color: #33cccc">'''BONUS'''</span> ====
image


While preparing this article, I came across another command, which I do not want to withhold from you. This command can be used in many ways, I want you to show a funny example for it.
Failure (EDGE01 Outage)


Since PowerShell 3.0 we can use the Invoke-RestMethod. That means we are able to put curl in our PowerShell. Here, my example what we can do with it:
If HUB01 can’t contact the EDGE01 within the time-out period after it has sent the message, the HUB01 resubmits the message to the EDGE02. The message in the Shadow Redundancy Queue now has the EDGE02 as the primary owner. If there is not alternative route the message won’t be resubmitted and remains in the shadow queue until the Auto Discard Interval is up.


&nbsp;
image
<div class="crayon-syntax crayon-theme-powershell crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-5ca464a0d3b3a670931980" style="margin-top: 12px;  margin-bottom: 12px;  font-size: 12px !important;  line-height: 15px !important;  height: auto"><div class="crayon-plain-wrap"><textarea class="crayon-plain print-no" data-settings="dblclick" readonly="readonly" style=" font-size: 12px !important;  line-height: 15px !important;  z-index: 0;  opacity: 0;  overflow: hidden" wrap="soft">(curl http://wttr.in/Zurich -UserAgent "curl" ).Content</textarea></div> <div class="crayon-main" style="position: relative;  z-index: 1;  overflow: hidden">
{| class="crayon-table" style=""
|- class="crayon-row"
| class="crayon-nums" data-settings="show" | <div class="crayon-nums-content" style="font-size: 12px !important;  line-height: 15px !important"><div class="crayon-num" data-line="crayon-5ca464a0d3b3a670931980-1">1</div> </div>
| class="crayon-code" | <div class="crayon-pre" style="font-size: 12px !important;  line-height: 15px !important;  -o-tab-size:4;  -webkit-tab-size:4;  tab-size:4"><div class="crayon-line" id="crayon-5ca464a0d3b3a670931980-1"><span class="crayon-sy">(</span><span class="crayon-e">curl </span><span class="crayon-v">http</span><span class="crayon-o">:</span><span class="crayon-c">//wttr.in/Zurich -UserAgent "curl" ).Content</span></div> </div>
|}
</div> </div>
&nbsp;


I am located in Zurich Switzerland, so for me, the weather here is important. When I run the command above, it will show me following result in my PowerShell console:
Temporary Failure


https://msb365.abstergo.ch/wp-content/uploads/2018/02/8-2.png<br/> Go and play around with this command a little bit. An overview of available options can be found here:&nbsp;[http://wttr.in/:help http://wttr.in/:help]
So what happens if the EDGE01 is temporary offline? For example the EDGE01 is down for let’s say 15 minutes when our time-out is 10 minutes and the retry is 0. This means that the message is resubmitted to the EDGE02 because the HUB01 isn’t sure that the message is delivered properly. In this case it’s possible that the message is already delivered and that the EDGE02 is delivering the same message ‘again’. Exchange mailbox users won’t see duplicate messages in their mailbox because Exchange has duplicate message detection. However recipients on other email systems may have a duplicate message if it doesn’t support duplicate message detection. For more information about duplicate message detection checkout this blog.

Dernière version du 22 juin 2022 à 11:53

https://sourcedaddy.com/windows-7/troubleshooting-exchange-server.html

Introduction

Cette page est destinée à contenir de vraies informations pratiques concernant les serveurs Exchange et comment les administrer, notamment en PowerShell.

Microsoft Exchange Server est un groupware (logiciel de groupe de travail) pour serveur de messagerie électronique créé par Microsoft. Il existe aussi en SaaS avec Office365.

Console ECP

La console ecp est accessible via https://<adresse>/ecp.

Elle permet de gérer la messagerie depuis une GUI.

Calendriers

Les calendriers (collectifs) sont liés à une adresse de type *utilisateur* (et non pas ressource, ce serait si logique). Un calendrier donne une adresse, à laquelle les gens sont sensés pouvoir accéder par OWA > ouvrir une autre boîte mail.

Ci-dessous, une commande pour donner des droits sur ce genre de calendrier à quelqu'un (testé mais pas validé...):

<syntaxhighlight lang="pshell"> PS Z:\> Add-MailboxFolderPermission -Identity "calendrier" -User "autre.user" -AccessRights "Contributor" FolderName User AccessRights


---- ------------

Haut de la banque... Anaise Leroy {Contributor}


PS Z:\> Get-MailboxFolderPermission -identity orientation-calendrier | fl </syntaxhighlight>


Commandes PowerShell

Boîtes partagées

<syntaxhighlight lang="pshell">

  1. Membres d'une BP

Get-Mailbox formation-continue-iae | Get-MailboxPermission | select identity,user,accessrights

</syntaxhighlight>

Autres

Sources:

Use the following commands to add or remove an email alias using Powershell commands:

To check current exchange mailbox aliases:

'''Get-Mailbox mailboxname | select -expand emailaddresses alias'''

To add an email alias to an exchange mailbox:

'''Set-Mailbox mailboxname -EmailAddresses @{Add='alias@somedomain.co.uk'}'''

To delete an email alias from an exchange mailbox:

Set-Mailbox mailboxname -EmailAddresses @{Remove=’alias@somedomain.co.uk’}

Re-lier une boîte dans une configuration avec une boîte liée

Dans un contexte avec plusieurs domaines AD, il se peut que les boîtes d'un domaine soient liées au comptes sur un autre domaine. Chaque boite est liée grâce au SID, un identifiant unique qui désigne le compte sur le domaine AD lié. Nous avons donc :

  • Un domaine 1 avec un AD.
  • Un autre domaine 2, avec des boîtes et avec son propre AD; mais pour une raison X les boites du domaine 2 sont liées au domaine 1.

Parfois, certaines boîtes peuvent se retrouver liées au mauvais SID. Voilà comment faire :

<syntaxhighlight lang="Powershell"> Get-Mailbox xxx@yyy | fl #On récupère les infos Disable-Mailbox xxx@yyy #On désactive la boîte d'une façon ou d'une autre Connect-Mailbox -LinkedDomainController "adc.domaine1" -LinkedMasterAccount "domaine1\madametruc" -Alias "truc" -Identity "Josiane Truc" -Database BASE-DB1 </syntaxhighlight>

Troubleshooting

MessageTrackingLog

Similaire à un maillog Linux, mais en moins pratique.

<syntaxhighlight lang="powershell"> Get-MessageTrackingLog -Recipients justine@domaine.fr Get-MessageTrackingLog -ResultSize Unlimited | Where-Object {$_.Recipients -like "*sarah.connor*"} Get-MessageTrackingLog -Start "09/30/2019 08:00:00" -End "09/30/2019 20:00:00" -Sender "luke.skywalker@rebellion.org" </syntaxhighlight>

On dispose bien entendu des autres logs Windows (voir Analyse de logs), mais ils ne sont pas pratiques non plus.

Commandes de test

PowerShell contient de nombreux cmdlets de test, et il serait bête de ne pas s'en servir !

On peut les voir toutes avec :

<syntaxhighlight lang='powershell'>

  1. Vérification du statuts des migrations en cours :
               Get-MoveRequest | where status -eq "InProgress" | Get-MoveRequestStatistics
  1. Vérification des users sur une database particulière :
               Get-Mailbox -database <db_name>
  1. Récupération des noms de databases :
               Get-MailboxDatabase
  1. Récupération des données Mailbox pour un utilisateur :
               Get-Mailbox <user>
  1. Récupération des données statistiques d’une mailbox :
               Get-mailbox <user> | get-mailboxstatistics
  1. Pour obtenir le maximum d’info, rajouter en fin de ligne : | fl

</syntaxhighlight>


Commandes de suivi des migrations

<syntaxhighlight lang="powershell">

  1. Vérification du statuts des migrations en cours :
Get-MoveRequest | where status -eq "InProgress" | Get-MoveRequestStatistics
  1. Vérification des users sur une database particulière :

Get-Mailbox -database <db_name>

  1. Récupération des noms de databases :

Get-MailboxDatabase

  1. Récupération des données Mailbox pour un utilisateur :

Get-Mailbox <user>

  1. Récupération des données statistiques d’une mailbox :

Get-mailbox <user> | get-mailboxstatistics

  1. Pour obtenir le maximum d’info, rajouter en fin de ligne : | fl

</syntaxhighlight>

Convertir une boite partagée en boite normale

Ici, je part de la boîte partagée "morpheus".

<source lang="powershell"> set-mailbox -id morpheus -type regular

  1. Une fois cela fait, il faut modifier l'utilisateur AD "morpheus" pour lui donner un mot de passe

</source>

Rôles d'une infra Exchange

MBX (Mailbox)

  • Héberge boîtes aux lettres / dossiers publics
  • Génération OAB / haute disponibilité CCR, SCC, LCR et SCR ou DAG
  • Ne fait pas le transport de messages (l’envoi / réception d'email échue si pas de serveur transport HUB)
  • Serveur membre du domaine

HUB

  • Catégorisation (résolution des destinataires) / conversion format de mails / routage des messages / règles de transport/ journalisation / taille maximum message envoyé et/ou reçu
  • Anti-spam (désactivé par défaut)
  • Serveur membre du domaine

CAS (Client Access Server)

  • Accès boîtes aux lettres via protocole NON MAPI (EAS, OWA, etc)
  • Les services WEB (Auto-Discover) / Distribution OAB
  • Serveur membre du domaine
  • En Exchange 2010, les clients Outlook se connectent sur le serveur CAS pas sur le serveur MAILBOX

EDGE

  • Joue le rôle de relais SMTP
  • Remise des messages Internet
  • Antispam
  • Analyse antivirus (nécessite une solution tierce)
  • Serveur NON membre du domaine et dans la DMZ

UM (Unified Messaging)

  • Réponse aux appels
  • Réception de télécopie
  • Accès à ses mails à distance via Outlook Voice Access (consulter ses messages et son calendrier via module vocal, accepter ou annuler des demandes de rendez-vous)
  • Machine membre du domaine
  • Non supporté en machine virtuelle
  • Nécessite IP-BPX / passerelle VoIP

Shadow redundancy (en lien avec les mentions HADISCARD du trackinglog)

https://pmeijden.wordpress.com/2011/06/01/shadow-redundancy-explained/

How it works

The HUB01 will deliver a message that is intended for a user outside the organization to the EDGE01 server. HUB01 detects that the EDGE01 supports shadow redundancy. HUB01 will move the message to the shadow redundancy queue and marks it with EDGE01 as the primary owner. When opening the Queue Viewer you’ll notice that there is one email in the Shadow Redundancy Queue.

clip_image002

Success

When EDGE01 delivers the message to the internet it updates the discard status of the message indicating that the delivery was successful. HUB01 will check the status of all sent messages (default every 15 minutes) by issuing a XQDISCARD command to EDGE01. EDGE01 will check the discard status and responds with a list of all the messages that are considered to be successfully delivered. HUB01 will delete the messages from the Shadow Redundancy Queue if they are on that list.

image

Failure (EDGE01 Outage)

If HUB01 can’t contact the EDGE01 within the time-out period after it has sent the message, the HUB01 resubmits the message to the EDGE02. The message in the Shadow Redundancy Queue now has the EDGE02 as the primary owner. If there is not alternative route the message won’t be resubmitted and remains in the shadow queue until the Auto Discard Interval is up.

image

Temporary Failure

So what happens if the EDGE01 is temporary offline? For example the EDGE01 is down for let’s say 15 minutes when our time-out is 10 minutes and the retry is 0. This means that the message is resubmitted to the EDGE02 because the HUB01 isn’t sure that the message is delivered properly. In this case it’s possible that the message is already delivered and that the EDGE02 is delivering the same message ‘again’. Exchange mailbox users won’t see duplicate messages in their mailbox because Exchange has duplicate message detection. However recipients on other email systems may have a duplicate message if it doesn’t support duplicate message detection. For more information about duplicate message detection checkout this blog.