+ Post New Thread
Page 1 of 3 123 LastLast
Results 1 to 15 of 45
Cloud Services Thread, Powershell - Office 365 - Any scripts? in Technical; Does anyone have scripts to do the following that they are willing to share? - Remove Lync license - Add ...
  1. #1

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180

    Powershell - Office 365 - Any scripts?

    Does anyone have scripts to do the following that they are willing to share?

    - Remove Lync license
    - Add and set as primary an additional SMTP address
    - Bulk update users email address in their AD account
    - Bulk set the various policies such as address book, retention, role assignment policy etc

  2. #2
    Boredguy's Avatar
    Join Date
    Jun 2011
    Location
    Swindon
    Posts
    569
    Thank Post
    3
    Thanked 128 Times in 119 Posts
    Rep Power
    50
    Quote Originally Posted by Edu-IT View Post
    Does anyone have scripts to do the following that they are willing to share?

    - Remove Lync license
    - Bulk set the various policies such as address book, retention, role assignment policy etc
    This post has the script we use for updating the users license and policies

    - Bulk update users email address in their AD account
    Code:
    #Get a list of the users in the Leavers Group
    $users = Get-ADGroupMember "Students"
    
    #Loop through the users
    FOREACH ($user in $users)
    {
    Set-ADUser $user.SamAccountName -EmailAddress ($user.SamAccountName + "@domainamehere.com")
    }
    should do what you need without testing it...

  3. Thanks to Boredguy from:

    Edu-IT (5th June 2014)

  4. #3

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Thanks for that. I looked at the script and notice you search for STU to identify students. How would I search for a number, let's say if username contains 14, 15 or 16. Do you know? Or would I just run the script three times and replace STU with 14* which I assume would mean the username begins with 14?

  5. #4

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Or could I specify license using job title?

    $users = Get-MsolUser -Title "Staff"

    ?
    Last edited by Edu-IT; 5th June 2014 at 09:33 PM.

  6. #5
    Boredguy's Avatar
    Join Date
    Jun 2011
    Location
    Swindon
    Posts
    569
    Thank Post
    3
    Thanked 128 Times in 119 Posts
    Rep Power
    50
    I specify our filter based on the start of the username, but you can use any field that has a value.

    This would get all our users (synchronised or cloud created) who's office field contains the value "Teaching Staff".
    Code:
    $users = Get-MsolUser -All | Where-Object {$_.Office -eq "Teaching Staff" }
    so for you
    Code:
    $users = Get-MsolUser -All | Where-Object {$_.Title -eq "Staff" }
    would return all users in 365 that have a Title configured as "Staff"

  7. #6

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Perfect, thanks.

  8. #7

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Anyone know how to add the SMTP address?

  9. #8
    Boredguy's Avatar
    Join Date
    Jun 2011
    Location
    Swindon
    Posts
    569
    Thank Post
    3
    Thanked 128 Times in 119 Posts
    Rep Power
    50
    Set-Mailbox -Identity john@yourdomain.com -Emailaddresses john.primaryaddress@yourdomain.com,i...therdomain.com

    The first entry after -Emailaddresses is the SMTP that will be the primary one.

  10. #9

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Sorry I meant in bulk for all users. I want to add an alias and set that as primary.

  11. #10

    FN-GM's Avatar
    Join Date
    Jun 2007
    Location
    UK
    Posts
    15,846
    Thank Post
    877
    Thanked 1,680 Times in 1,460 Posts
    Blog Entries
    12
    Rep Power
    444
    Do you use DIRSYNC? If so you need to do that on premise AD not on 365.

  12. #11

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    No, not at all

  13. #12
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    462
    Thank Post
    72
    Thanked 57 Times in 48 Posts
    Blog Entries
    1
    Rep Power
    17

    Powershell - Office 365 - Any scripts?

    Get-Mailbox -ResultSize unlimited -Filter {RecipientTypeDetails -eq 'UserMailbox'} | foreach Set-Mailbox -Identity $_ -Emailaddresses $_.SAMAccountName@yourdomain.com

    I've not tested this as I have a DIRsync'd environment but I think this should work.

  14. #13

    Join Date
    Aug 2013
    Posts
    29
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Mostly on-topic - we're about to switch over to 365 from an on-premise Exchange. I can't disconnect the mailboxes until next week, but once I do this, do I just need to run an internal powershell script to set an attribute which will be picked up by 365 as the address to use when I apply the 365 licenses? We're ADFS 3.0 with DIRSYNC.

  15. #14

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,047
    Thank Post
    160
    Thanked 913 Times in 716 Posts
    Blog Entries
    3
    Rep Power
    271
    Hi Edu-IT,

    In order to create a script that will do what you require it is important to understand where the data is coming from to which you want to add the SMTP Addresses? i.e. are you going to use SAMAccountName@domain.com ? or are you looking to use another prefix. Once I know this then it may be possible to pull the data from Active Directory to then create a script that then goes and set's new ProxyAddresses based on information pulled from Active Directory?

    Unless you have a CSV with the additional proxy addresses we could work with that aswell.

    Thanks,
    James.

  16. #15

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,121
    Thank Post
    403
    Thanked 619 Times in 566 Posts
    Rep Power
    180
    Quote Originally Posted by EduTech View Post
    Hi Edu-IT,

    In order to create a script that will do what you require it is important to understand where the data is coming from to which you want to add the SMTP Addresses? i.e. are you going to use SAMAccountName@domain.com ? or are you looking to use another prefix. Once I know this then it may be possible to pull the data from Active Directory to then create a script that then goes and set's new ProxyAddresses based on information pulled from Active Directory?

    Unless you have a CSV with the additional proxy addresses we could work with that aswell.

    Thanks,
    James.
    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.

SHARE:
+ Post New Thread
Page 1 of 3 123 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
  •