Jump to content

Recommended Posts

Posted
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.

  • 2 weeks later...
Posted
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

}

Posted
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?
Posted
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?

Posted

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”}}

Posted
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.

Posted
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 :o)

@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.

Posted
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 :o)

@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?

Posted
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"}

  • Thanks 1
Posted

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.

Posted
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 :o)

@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? :p I'm new to Powershell so if I'm wrong please let me know!

Posted
Who's missing something here? :p 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.

  • 3 weeks later...
Posted
@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.
Posted

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 }

 

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...