Pegasi Wiki

This wiki acts as a memo for our own work so why not share them? Feel free to browse and use out notes and leave a note while at it.

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
create_and_manage_office_365_mailusers_with_powershell [2017/09/16 13:46]
Pekka Kuronen
create_and_manage_office_365_mailusers_with_powershell [2017/11/06 10:11] (current)
Line 1: Line 1:
-===== Manage Office 365 mailusers with multiple proxyAddresses using Microsoft Powershell =====+====== Manage Office 365 mailusers with multiple proxyAddresses using Microsoft Powershell ​======
  
 For some reason the Microsoft (and other) documents are restrained to situations where mailuser does not have multiple email addresses which in my case is not realistic. Somehow this reminds me of Jim Carrey karate instructor lessons. :) For some reason the Microsoft (and other) documents are restrained to situations where mailuser does not have multiple email addresses which in my case is not realistic. Somehow this reminds me of Jim Carrey karate instructor lessons. :)
Line 5: Line 5:
 Anyway I wrote down here how to enable, manage and disable Office 365 mailusers with multiple proxyAddresses using Powershell command line tools for automatic scripting. Also included is existing mailuser checking and try - catch method for error handling. Anyway I wrote down here how to enable, manage and disable Office 365 mailusers with multiple proxyAddresses using Powershell command line tools for automatic scripting. Also included is existing mailuser checking and try - catch method for error handling.
  
-==== Set up a session ====+The below stuff is tested on live environment and should work but please let me know if there is something that I should correct. 
 + 
 +===== Set up a session ​=====
  
 For completeness sake here is the common things you need to do before you can talk with Exchange / Office 365 For completeness sake here is the common things you need to do before you can talk with Exchange / Office 365
Line 17: Line 19:
 In addition to that you may need to set up variables for mail and proxyAddresses. In addition to that you may need to set up variables for mail and proxyAddresses.
  
-==== Find out if mailuser exists ====+===== Find out if mailuser exists ​=====
  
 We must know if we want to Enable-MailUser or Set-MailUser. Please note that Get-MailUser throws an error if user is not found so you must use try-catch. We must know if we want to Enable-MailUser or Set-MailUser. Please note that Get-MailUser throws an error if user is not found so you must use try-catch.
Line 31: Line 33:
 </​code>​ </​code>​
  
-==== New mailuser ====+===== New mailuser ​=====
  
 If we have an AD user but no existing mail account we can do the following: If we have an AD user but no existing mail account we can do the following:
Line 59: Line 61:
 </​code>​ </​code>​
  
-==== Existing mailuser ====+===== Existing mailuser ​=====
  
 Now we only need update the values to the mailuser using Set-Mailuser. Now we only need update the values to the mailuser using Set-Mailuser.
Line 74: Line 76:
 } }
 </​code>​ </​code>​
 +
 +===== Removing session =====
 +
 +In the end we wish to terminate session.
 +
 +<​code>​
 +Remove-PSSession $Session
 +</​code>​
 +
 +And that's about it.
  
 ====== Comments and suggestions ====== ====== Comments and suggestions ======
Line 82: Line 94:
 {(rater>​id=create_and_manage_office_365_mailusers_with_powershell|type=rate|trace=ip|tracedetails=0|headline=off)} {(rater>​id=create_and_manage_office_365_mailusers_with_powershell|type=rate|trace=ip|tracedetails=0|headline=off)}
  
-~~DISCUSSION|Leave a comment~~+~~DISCUSSION|Leave a comment~~~~NOCACHE~~ 
 +~~QUICKSTATS:​@create_and_manage_office_365_mailusers_with_powershell&​basics~~ 
 +~~QUICKSTATS:​@create_and_manage_office_365_mailusers_with_powershell&​ip~~ 

  //check if we are running within the DokuWiki environment if (!defined("DOKU_INC")){ die(); } //place the needed HTML source codes BELOW this line