Solved

Quest Cmdlet Powershell script to update mail/email attribute on user objects in AD

Posted on 2011-02-25
12
1,802 Views
Last Modified: 2012-05-11
Hello,  I would like to update all users in our AD, local domain, with a email address in the mail attribute of the user object.  mail  = givenname+'@mail.com' .  I am new to using quest cmdlets & powershell.  
this is what i am starting with, but having trouble
Get-QADUser -SearchRoot * | -LdapFilter '(mail='')|   set-qaduser -email "$_.givename@mail.com"

All help is greatly appreciated. thanks
0
Comment
Question by:sp5980
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 37

Expert Comment

by:Neil Russell
ID: 34980429
What version of exchange are you using? What you are talking about is applying a recipient policy.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34980453
Try this, but if you have Exchange it would be easier to create a email policy. And if you have two people with the same first names this could case an problem.

Get-QADUser -SearchRoot "OU=USERSOU,DC=Domain,DC=Local" -LdapFilter "(mail=*)" | set-qaduser -email "$($_.givename)@mail.com"
0
 

Author Comment

by:sp5980
ID: 34980586
Thank you for your comments, i forgot to add, we do not run exchange within our dept.  We are a dept..  in a university.  Email/exchange is handled by central IT group .  And have seperate mgmt & IT domains.  buerocracy at its finest.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:sp5980
ID: 34980663
should i use "$_.sAMAccountname" instead of "$_.givenname"?  That should give unique results.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34980685
Yes, I would recomend useing samaccountname. That can not be duplicated.
0
 

Author Comment

by:sp5980
ID: 34980749
i just ran the script & it didnt add the givenname to teh mail..  the email just shows "@mail.com'
please advise.
0
 
LVL 27

Expert Comment

by:KenMcF
ID: 34980787
ok, try this

Get-QADUser -SearchRoot "OU=USERSOU,DC=Domain,DC=Local" -LdapFilter "(mail=*)" | %{set-qaduser $_ -email "$($_.samaccountname)@mail.com"}
0
 

Author Comment

by:sp5980
ID: 34980856
PS C:\Windows\system32> Get-QADUser -SearchRoot "OU=DevClients,DC=SDOS,DC=Local" -LdapFilter "(mail=*)" | set-qaduser -email "$($_.samaccountname)@gmail.com"
result mail = @gmail.com.
     
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 34980887
You didnt change it. See my last post. Wrap the set-qaduser in a foreach loop

Get-QADUser -SearchRoot "OU=USERSOU,DC=Domain,DC=Local" -LdapFilter "(mail=*)" | %{set-qaduser $_ -email "$($_.samaccountname)@mail.com"}
0
 

Author Comment

by:sp5980
ID: 34980922
Thanks, i got the error below
PS C:\Windows\system32> Get-QADUser -SearchRoot "OU=DevClients,DC=Domain,DC=Local" -LdapFilter "(mail=*)" | %{set-qaduser $_ -email "$($_.samaccountname)@mail.com"}
Get-QADUser : A referral was returned from the server. (Exception from HRESULT: 0x8007202B)
At line:1 char:12
+ Get-QADUser <<<<  -SearchRoot "OU=DevClients,DC=Domain,DC=Local" -LdapFilter "(mail=*)" | %{set-q
aduser $_ -email "$($_.samaccountname)@mail.com"}
    + CategoryInfo          : NotSpecified: (:) [Get-QADUser], COMException
    + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPow
   erShellSnapIn.Powershell.Cmdlets.GetUserCmdlet
0
 

Author Comment

by:sp5980
ID: 34980942
oops, ignore, forgot to change the domain text.
0
 

Author Comment

by:sp5980
ID: 34980952
tried again & it worked!!!   Thanks experts
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question