foofighterjim Posted July 8, 2014 Posted July 8, 2014 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
EduTech Posted July 8, 2014 Posted July 8, 2014 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.
Edu-IT Posted July 8, 2014 Author Posted July 8, 2014 No, I want to use the first part of the UPN. The bit before the @.
Edu-IT Posted July 19, 2014 Author Posted July 19, 2014 Anyone have a script to bulk update the UPN suffix in AD for a particular OU?
Marshall_IT Posted July 19, 2014 Posted July 19, 2014 Use wyse soft bulk ad modify http://www.wisesoft.co.uk/software/bulkadusers/bulkmodify.aspx
apearce Posted July 20, 2014 Posted July 20, 2014 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 }
Edu-IT Posted July 28, 2014 Author Posted July 28, 2014 This post has the script we use for updating the users license and policies #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?
Edu-IT Posted July 28, 2014 Author Posted July 28, 2014 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?
apearce Posted July 28, 2014 Posted July 28, 2014 Nothing comes to mind other than there might be a different suffix for the user or they don't have a UPN.
Edu-IT Posted July 28, 2014 Author Posted July 28, 2014 This is driving me cuckoo now. Does anyone have a script that will update the emails in AD?
Blue_Cookeh Posted July 28, 2014 Posted July 28, 2014 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. 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”}}
Edu-IT Posted July 28, 2014 Author Posted July 28, 2014 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. 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.
Marshall_IT Posted July 28, 2014 Posted July 28, 2014 Have you looked at wise soft bulk ad modify? I used this to update all my email addresses r to username domain. Co. UK
Edu-IT Posted July 28, 2014 Author Posted July 28, 2014 What do I specify in the email box on that to take the logon name and add the suffix?
Marshall_IT Posted July 28, 2014 Posted July 28, 2014 Use this guide http://www.wisesoft.co.uk/software/bulkadusers/bulkmodify.aspx I guess it would be something like sAMAccountName@domain.co.uk
EduTech Posted July 28, 2014 Posted July 28, 2014 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. 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.
aceonbass Posted July 29, 2014 Posted July 29, 2014 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?
aceonbass Posted July 29, 2014 Posted July 29, 2014 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: 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"} 1
aceonbass Posted July 30, 2014 Posted July 30, 2014 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.
Blue_Cookeh Posted August 1, 2014 Posted August 1, 2014 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. But he's specified a -SearchBase and it looks to be a test OU, therefore he'll only get users under that OU? Who's missing something here? I'm new to Powershell so if I'm wrong please let me know!
EduTech Posted August 1, 2014 Posted August 1, 2014 Who's missing something here? I'm new to Powershell so if I'm wrong please let me know! I didn't see the -searchbase so that of course is much quicker than not having it {otherwise it would of got everything from AD}. Setting the searchbase and changing it is a better optimized query unless you use the root DSE ;-) I just saw Get-ADUser and didn't read on ;-) James.
Edu-IT Posted August 19, 2014 Author Posted August 19, 2014 @EduTech - Did you figure out a Powershell on how I can take the bit before the @ on the users UPN, and add it to a different suffix as a primary SMTP? So Office365 has a different Primary SMTP to what is currently set.
Edu-IT Posted August 19, 2014 Author Posted August 19, 2014 Okay, so this will add the alias but what do I insert in to this to make this one the primary SMTP? $Mailboxes = Get-Mailbox Foreach ($Mailbox in $Mailboxes) { $NewAddress = $Mailbox.Alias + "@o365info.com" $Mailbox.EmailAddresses += $NewAddress Set-Mailbox -Identity $Mailbox.Alias -EmailAddresses $Mailbox.EmailAddresses }
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now