+ Post New Thread
Page 3 of 4 FirstFirst 1234 LastLast
Results 31 to 45 of 49
Cloud Services Thread, Powershell - Office 365 - Any scripts? in Technical; Originally Posted by Edu-IT Anyone have a script to bulk update the UPN suffix in AD for a particular OU? ...
  1. #31

    Join Date
    Feb 2008
    Location
    Birmingham
    Posts
    418
    Thank Post
    36
    Thanked 176 Times in 111 Posts
    Rep Power
    43
    Quote Originally Posted by Edu-IT View Post
    Anyone have a script to bulk update the UPN suffix in AD for a particular OU?
    Try this

    import-module ActiveDirectory

    #Replace with the old suffix
    $oldSuffix = '@bfc.local'

    #Replace with the new suffix
    $newSuffix = '@bfcnetworks.com'

    #Replace with the OU you want to change suffixes for
    $ou = "OU=Users,DC=bfc,DC=local"

    Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
    $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix )
    $_ | Set-ADUser -UserPrincipalName $newUpn
    }

  2. #32

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    Thank you both.

  3. #33

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    Quote Originally Posted by Boredguy View Post
    This post has the script we use for updating the users license and policies


    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...
    That doesn't seem to work? Any ideas?

  4. #34

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    Quote Originally Posted by apearce View Post
    Try this

    import-module ActiveDirectory

    #Replace with the old suffix
    $oldSuffix = '@bfc.local'

    #Replace with the new suffix
    $newSuffix = '@bfcnetworks.com'

    #Replace with the OU you want to change suffixes for
    $ou = "OU=Users,DC=bfc,DC=local"

    Get-ADUser -SearchBase $ou -filter * | ForEach-Object {
    $newUpn = $_.UserPrincipalName.Replace($oldSuffix,$newSuffix )
    $_ | Set-ADUser -UserPrincipalName $newUpn
    }
    Any ideas why this script would change most, but miss out a few?

  5. #35

    Join Date
    Feb 2008
    Location
    Birmingham
    Posts
    418
    Thank Post
    36
    Thanked 176 Times in 111 Posts
    Rep Power
    43
    Nothing comes to mind other than there might be a different suffix for the user or they don't have a UPN.

  6. #36

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    This is driving me cuckoo now. Does anyone have a script that will update the emails in AD?

  7. #37

    Join Date
    Aug 2009
    Posts
    280
    Thank Post
    20
    Thanked 22 Times in 19 Posts
    Rep Power
    14
    Had to update proxyAddresses today since we use different usernames on premises compared to Office365, used this Powershell on a DC to do it in a particular OU. It gets the user's first and last name from AD then sets their SMTP proxy address. Might be useful to someone. It should all be on one line.

    Code:
    get-aduser -searchbase "OU=test,DC=domain-internal,DC=co,DC=uk" -Filter * -Properties ProxyAddresses,GivenName,Surname | foreach {set-aduser -Identity $_.SamAccountName -Add @{ProxyAddresses=“SMTP:”+$_.givenname+”.”+$._surname+”@domain-external.co.uk”}}

  8. #38

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    Quote Originally Posted by Blue_Cookeh View Post
    Had to update proxyAddresses today since we use different usernames on premises compared to Office365, used this Powershell on a DC to do it in a particular OU. It gets the user's first and last name from AD then sets their SMTP proxy address. Might be useful to someone. It should all be on one line.

    Code:
    get-aduser -searchbase "OU=test,DC=domain-internal,DC=co,DC=uk" -Filter * -Properties ProxyAddresses,GivenName,Surname | foreach {set-aduser -Identity $_.SamAccountName -Add @{ProxyAddresses=“SMTP:”+$_.givenname+”.”+$._surname+”@domain-external.co.uk”}}
    That's the sort of thing I need but I want to use their logon name.

  9. #39
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    606
    Thank Post
    80
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23
    Have you looked at wise soft bulk ad modify? I used this to update all my email addresses r to username domain. Co. UK

  10. #40

    Edu-IT's Avatar
    Join Date
    Nov 2007
    Posts
    7,259
    Thank Post
    404
    Thanked 633 Times in 578 Posts
    Rep Power
    185
    What do I specify in the email box on that to take the logon name and add the suffix?

  11. #41
    Marshall_IT's Avatar
    Join Date
    Jul 2011
    Location
    Leeds
    Posts
    606
    Thank Post
    80
    Thanked 86 Times in 70 Posts
    Blog Entries
    1
    Rep Power
    23
    Use this guide http://www.wisesoft.co.uk/software/b...ulkmodify.aspx

    I guess it would be something like <attr>sAMAccountName</attr>@domain.co.uk

  12. #42

    EduTech's Avatar
    Join Date
    Aug 2007
    Location
    Reading
    Posts
    5,074
    Thank Post
    160
    Thanked 937 Times in 731 Posts
    Blog Entries
    3
    Rep Power
    275
    Quote Originally Posted by Blue_Cookeh View Post
    Had to update proxyAddresses today since we use different usernames on premises compared to Office365, used this Powershell on a DC to do it in a particular OU. It gets the user's first and last name from AD then sets their SMTP proxy address. Might be useful to someone. It should all be on one line.

    Code:
    get-aduser -searchbase "OU=test,DC=domain-internal,DC=co,DC=uk" -Filter * -Properties ProxyAddresses,GivenName,Surname | foreach {set-aduser -Identity $_.SamAccountName -Add @{ProxyAddresses=“SMTP:”+$_.givenname+”.”+$._surname+”@domain-external.co.uk”}}
    You do realize that the first part of that command before the | is going to go and get every single user within AD ;-) which in organizations where by they have 1,000s of user accounts it could take sometime )
    @Edu-IT

    If I was you I would encourage you to have a look at the WiseSoft Bulk AD Update tool in order to do this.

    James.

  13. #43

    Join Date
    Aug 2013
    Posts
    31
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Quote Originally Posted by EduTech View Post
    You do realize that the first part of that command before the | is going to go and get every single user within AD ;-) which in organizations where by they have 1,000s of user accounts it could take sometime )
    @Edu-IT .
    But he's specified a -SearchBase and it looks to be a test OU, therefore he'll only get users under that OU?

  14. #44

    Join Date
    Aug 2013
    Posts
    31
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Quote Originally Posted by Edu-IT View Post
    That's the sort of thing I need but I want to use their logon name.
    I just blasted our AD with this code, setting their email address to their username (samaccountname) @domain.ac.uk:

    Code:
    Get-ADUser -Filter * -SearchBase "OU=Departments,DC=students,DC=domain,DC=ac,DC=uk" | Foreach-Object{Set-ADUser -Identity $_ -Email "$($_.samaccountname)@students.domain.ac.uk"}

  15. #45

    Join Date
    Aug 2013
    Posts
    31
    Thank Post
    5
    Thanked 1 Time in 1 Post
    Rep Power
    0
    Does anyone know if we can apply multiple licenses with the -AddLicenses switch in Set-MsolUserLicense? I can't seem to find any information or examples of others doing this. I'm currently running separate scripts for A2 and Student Advantage (with appropriate logic for unlicensed/only have A2 license etc) and was hoping I could combine into one script. We don't apply any license options and just give them the full whack of each.

    Cheers.



SHARE:
+ Post New Thread
Page 3 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, 08:15 PM
  2. office 365 migration script issue
    By kweng7 in forum Cloud Services
    Replies: 4
    Last Post: 17th August 2013, 02:19 AM
  3. Bulk change Office 365 user names using Powershell?
    By adamf in forum Cloud Services
    Replies: 7
    Last Post: 10th July 2013, 09: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, 09:37 PM
  5. Office 365 Useful Powershell
    By sottonk in forum Cloud Services
    Replies: 2
    Last Post: 8th March 2013, 02: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
  •