+ Post New Thread
Page 2 of 4 FirstFirst 1234 LastLast
Results 16 to 30 of 49
Cloud Services Thread, Powershell - Office 365 - Any scripts? in Technical; Originally Posted by Edu-IT Example. They are provisioned with initialsurname@domain.com . I want to add, and make the primary, initialsurname@domain.co.uk ...
  1. #16
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    509
    Thank Post
    76
    Thanked 63 Times in 54 Posts
    Blog Entries
    1
    Rep Power
    19
    Quote Originally Posted by Edu-IT View Post
    Example.

    They are provisioned with initialsurname@domain.com. I want to add, and make the primary, initialsurname@domain.co.uk.

    All the domains are added in Office 365.
    What is their current upn? If it is initialsurname@ then we could use that and select the first section of the string.

  2. #17

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,068
    Thank Post
    160
    Thanked 925 Times in 727 Posts
    Blog Entries
    3
    Rep Power
    273
    please test before running in production.

    Get-Mailbox | % {$newmail = ($_.emailaddresses | ? {$_ -imatch 'SMTP\:\w+\@sub\.edutech\.me\.uk'}) -replace 'sub\.edutech\.me\.uk', 'sub1.edutech.me.uk';$newmail}
    If you run the following it will give you an output and allow you to see the changes, so what this does is take all of your existing SMTP addresses for the users and it will grab the existing domain and then using regex will then add an SMTP address that matches the existing pre-fix with the new domain.

    If you run the above command, it will output it to powershell console.. have a look over it and see if that is what you want to do. if it is, then i shall give you the command to write these values back. :-)

    NOTE you have to replace my domain with yours... and for each . you need to put a \ before hand. hopefully you follow my logic.

    James.

  3. #18

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Doesn't seem to do anything?

  4. #19

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,068
    Thank Post
    160
    Thanked 925 Times in 727 Posts
    Blog Entries
    3
    Rep Power
    273
    Quote Originally Posted by Edu-IT View Post
    Doesn't seem to do anything?
    can you send me a PM with the command that you run i imagine you didn't replace the syntax correctly.

    James.

  5. #20

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Ah I know why. That seems to work but I have some uppercase SMTP and some lower showing?

  6. #21

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Quote Originally Posted by Marshall_IT View Post
    What is their current upn? If it is initialsurname@ then we could use that and select the first section of the string.
    Their current UPN is what I want to use, yes.

  7. #22

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,068
    Thank Post
    160
    Thanked 925 Times in 727 Posts
    Blog Entries
    3
    Rep Power
    273
    ok,

    do the following command first against a test account to make sure it does what you want..

    Get-Mailbox someone@domain.co.uk | % {$mail = $_.EmailAddresses -creplace 'SMTP', 'smtp';$mail += "SMTP:$($_.UserPrincipalName)";Set-Mailbox -Identity $_.UserPrincipalName -EmailAddresses $mail}
    If that works fine then you can run this and it will do it for them all.

    Get-Mailbox | % {$mail = $_.EmailAddresses -creplace 'SMTP', 'smtp';$mail += "SMTP:$($_.UserPrincipalName)";Set-Mailbox -Identity $_.UserPrincipalName -EmailAddresses $mail}
    Regards,
    James.
    Last edited by EduTech; 8th July 2014 at 01:08 PM.

  8. #23

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    What parts do I need to change in that?

  9. #24

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,068
    Thank Post
    160
    Thanked 925 Times in 727 Posts
    Blog Entries
    3
    Rep Power
    273
    Quote Originally Posted by Edu-IT View Post
    What parts do I need to change in that?
    the first command you just need to replace someone@domain.co.uk so that you can do a test, and then the second command you don't need to change anything it will do it for all users.

    James.

  10. #25

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    Quote Originally Posted by EduTech View Post
    please test before running in production.



    If you run the following it will give you an output and allow you to see the changes, so what this does is take all of your existing SMTP addresses for the users and it will grab the existing domain and then using regex will then add an SMTP address that matches the existing pre-fix with the new domain.

    If you run the above command, it will output it to powershell console.. have a look over it and see if that is what you want to do. if it is, then i shall give you the command to write these values back. :-)

    NOTE you have to replace my domain with yours... and for each . you need to put a \ before hand. hopefully you follow my logic.

    James.
    So I need to run this first, then that one? Reason I ask is that I can't see how the script knows what domain to use?

    Get-Mailbox | % {$mail = $_.EmailAddresses -creplace 'SMTP', 'smtp';$mail += "SMTP:$($_.UserPrincipalName)";Set-Mailbox -Identity $_.UserPrincipalName -EmailAddresses $mail}
    Last edited by Edu-IT; 8th July 2014 at 02:35 PM.

  11. #26
    foofighterjim's Avatar
    Join Date
    Nov 2011
    Location
    Birmingham
    Posts
    414
    Thank Post
    30
    Thanked 77 Times in 59 Posts
    Rep Power
    28
    A good webpage to look at to figure out what commands do what: Manage Azure AD using Windows PowerShell

    - - - Updated - - -

    A good webpage to look at to figure out what commands do what: http://technet.microsoft.com/en-us/library/jj151815.aspx

  12. #27

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,068
    Thank Post
    160
    Thanked 925 Times in 727 Posts
    Blog Entries
    3
    Rep Power
    273
    Quote Originally Posted by Edu-IT View Post
    So I need to run this first, then that one? Reason I ask is that I can't see how the script knows what domain to use?

    Get-Mailbox | % {$mail = $_.EmailAddresses -creplace 'SMTP', 'smtp';$mail += "SMTP:$($_.UserPrincipalName)";Set-Mailbox -Identity $_.UserPrincipalName -EmailAddresses $mail}
    You said that you wanted to set Proxy Address based on the current UPN is that not the case?

    James.

  13. #28

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181
    No, I want to use the first part of the UPN. The bit before the @.

  14. #29

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,157
    Thank Post
    403
    Thanked 623 Times in 569 Posts
    Rep Power
    181

    Powershell - Office 365 - Any scripts?

    Anyone have a script to bulk update the UPN suffix in AD for a particular OU?

  15. #30
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    509
    Thank Post
    76
    Thanked 63 Times in 54 Posts
    Blog Entries
    1
    Rep Power
    19

SHARE:
+ Post New Thread
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. Office 365 Licensing Powershell Query
    By Mr.Ben in forum Cloud Services
    Replies: 13
    Last Post: 22nd April 2014, 07:15 PM
  2. office 365 migration script issue
    By kweng7 in forum Cloud Services
    Replies: 4
    Last Post: 17th August 2013, 01:19 AM
  3. Bulk change Office 365 user names using Powershell?
    By adamf in forum Cloud Services
    Replies: 7
    Last Post: 10th July 2013, 08:14 AM
  4. Office 365 Powershell command, not doing what I expect
    By mbedford in forum Cloud Services
    Replies: 3
    Last Post: 7th June 2013, 08:37 PM
  5. Office 365 Useful Powershell
    By sottonk in forum Cloud Services
    Replies: 2
    Last Post: 8th March 2013, 01:54 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •