|
|
Ligne 8 : |
Ligne 8 : |
| = Commandes PowerShell = | | = Commandes PowerShell = |
|
| |
|
| Sources : | | Sources : |
|
| |
|
| *https://www.msb365.blog/?p=1388 | | *[https://www.msb365.blog/?p=1388 https://www.msb365.blog/?p=1388] |
| | | <pdf>Fichier:Exch.pdf</pdf> |
| ==== 1 GET-MIGRATIONUSER ====
| |
| | |
|
| |
| | |
| 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:
| |
| <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>
| |
|
| |
| | |
| After I am connected to my endpoint, I can check the status of the migration batch with 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-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">
| |
| {| 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-5ca464a0d3ad8637173528-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-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">|</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 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:
| |
| <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">
| |
| {| 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">|</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">|</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 to keep an easy overview of huge migration batches .
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 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
| |
| | |
|
| |
| | |
| 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 [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 > "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">|</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
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 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>
| |
|
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 4 SET-MAILBOXAUTOREPLYCONFIGURATION ====
| |
| | |
| Ready for number 4? 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>
| |
|
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 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 ” 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…
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 6 GET-PARTNERAPPLICATION ====
| |
| | |
| 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.
| |
| | |
| 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.
| |
| | |
|
| |
| | |
| Microsoft describes this function like:
| |
| | |
| 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.
| |
| | |
| So, here´s an example how this command works for us:
| |
| | |
| 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-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.
| |
| | |
|
| |
| | |
| Another example is, when we want to create a new HRApp partner application called HRApp:
| |
| <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.
| |
| | |
|
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 7 NEW-ITEM ====
| |
| | |
| 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.
| |
| | |
| To create a directory with PowerShell we simply need one command: New-Item.
| |
| | |
|
| |
| | |
| With the New-Item cmdlet we can create different things like directories, files, registry keys, etc.
| |
| | |
| Here are some examples how to use it:
| |
| | |
| If we want to create a new directory on the C:\ partition for our PowerShell scripts, we can go with this command:
| |
| <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">
| |
| {| 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>
| |
|
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 8 NEW-MSOLUSER ====
| |
| | |
| Let’s talk abit about the Office 365 cloud now. The next command is more known by using its bro ''Get-MsolUser''.
| |
| | |
| 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…
| |
| | |
| If we need to create one new user, we can 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-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 <DisplayName> -FirstName <FirstName> -LastName <LastName> -UserPrincipalName <Account> -UsageLocation <CountryCode> -LicenseAssignment <AccountSkuID> [-Password <Password>]</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-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!
| |
| | |
|
| |
| | |
| First we need to create a CSV file. This can 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-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">
| |
| {| 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>
| |
|
| |
| | |
| After we have created this file, 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-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 <Input CSV File Path and Name> | foreach {New-MsolUser -DisplayName $_.DisplayName -FirstName $_.FirstName -LastName $_.LastName -UserPrincipalName $_.UserPrincipalName -UsageLocation $_.UsageLocation -LicenseAssignment $_.AccountSkuId [-Password $_.Password]} | Export-Csv -Path <Output CSV File Path and Name></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-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">|</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">|</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
| |
| | |
|
| |
| | |
| With the New-MsolUser cmdlet we can also create new users and assign a license straight away:
| |
| <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>
| |
|
| |
| | |
| There are also a bulk of optional parameters:
| |
| <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 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 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>
| |
|
| |
| | |
| ----
| |
| | |
| ==== 9 GET-HOTFIX ====
| |
| | |
| 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.
| |
| | |
| 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:
| |
| <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">
| |
| {| 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-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>
| |
|
| |
| | |
| And as we see in the print screen, there are just a few updates installed on my machine:
| |
| | |
| https://msb365.abstergo.ch/wp-content/uploads/2018/02/6-4.png
| |
| | |
| 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:
| |
| <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>
| |
|
| |
| | |
| As we see, there are a couple of patches installed:
| |
| | |
| https://msb365.abstergo.ch/wp-content/uploads/2018/02/7-2.png
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== 10 NEW-MANAGEMENTROLEASSIGNMENT ====
| |
| | |
| 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…
| |
| | |
| In the first example, I have to assign the Mail Recipient role to the 2<sup>nd</sup> level helpdesk of our company. To do that I 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-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>
| |
|
| |
| | |
| 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:
| |
| <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">|</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>
| |
|
| |
| | |
| After the role has been verified to be an end-user role, the role is assigned to the “Sales end-users” role assignment policy.
| |
| <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>
| |
|
| |
| | |
| ----
| |
| | |
|
| |
| | |
| ==== <span style="color: #33cccc">'''BONUS'''</span> ====
| |
| | |
| 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.
| |
| | |
| 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:
| |
| | |
|
| |
| <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>
| |
|
| |
| | |
| 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:
| |
| | |
| 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: [http://wttr.in/:help http://wttr.in/:help]
| |