VBScript to export sAMAccount name and Primary SMTP from a list of displayNames
Hi All, I don't know much about scripting. We are still using Exchange 2003 servers. I have a list of displayNames with me. Please let me know if there is a VBScript solution to get these displayName attribute as input and export their corresponding sAMAccountname attribute and their Primary SMTP addresses (Need to read Only Primary SMTP from the proxyaddresses attribute) This would be helpful as i am in the process of working out oab issues
April 29th, 2012 4:44pm

VBscripting is SO 2005! Use Powershell. Exchange 2003 doesn't have any of it's own cmdlets, but there are some very popular, free ones you can download here: http://www.quest.com/powershell/activeroles-server.aspx Once you run the installer you can use the cmdlets against active directory, which is where this information is stored. For example, your txt file of display names can be fed in like this: Get-Content C:\UserList.txt | Get-QADUser | ft displayname, samaccountname, email example txt file and output: Mike Crowley | MVP My Blog -- Planet Technologies
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2012 1:12am

Thank you so much Mike for the solution. Will try it tomorrow and let you know the result. I guess, the command given by you will pull the email address stored in the "mail" attribute. But i need just the Primary SMTP address which is stored in the proxyAddresses attribute to be shown in the output. Is it possible to pull the Primary SMTP? Thanks Again Frederick
April 30th, 2012 2:12pm

Thank you so much Mike for the solution. Will try it tomorrow and let you know the result. I guess, the command given by you will pull the email address stored in the "mail" attribute. But i need just the Primary SMTP address which is stored in the proxyAddresses attribute to be shown in the output. Is it possible to pull the Primary SMTP? Thanks Again Frederick
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2012 2:12pm

I wasn't sure you'd notice that. ;) When setting the primary email address by any Exchange tool, the AD "mail" attribute is set to the same value. Therefore, unless you have another system making changes to "mail" directly, they will always be the same. If you want to get the primary email address from the proxyaddress attribute, you must first enumerate all of the values and then look for the one with the uppercase SMTP. This is of course more complicated. If this is what you need, I'll write an updated script, but I'd suggest you try with what I supplied above. Mike Crowley | MVP My Blog -- Planet Technologies
April 30th, 2012 4:05pm

I wasn't sure you'd notice that. ;) When setting the primary email address by any Exchange tool, the AD "mail" attribute is set to the same value. Therefore, unless you have another system making changes to "mail" directly, they will always be the same. If you want to get the primary email address from the proxyaddress attribute, you must first enumerate all of the values and then look for the one with the uppercase SMTP. This is of course more complicated. If this is what you need, I'll write an updated script, but I'd suggest you try with what I supplied above. Mike Crowley | MVP My Blog -- Planet Technologies
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2012 4:05pm

Thanks Mike for the reply, I should have given you more details :-) Actually i am in the process of working out OAB issues in our organization. Mail boxes will be skipped in the process of OAB generation when the "mail" attribute does not match with the Primary SMTP in proxyAddresses tab. I have a list of around 2000 mailboxes which have such issues, Mail attribute not matching the primary SMTP. I have only the displayNames of those mailboxes with me. I have a vbscript which will modify the "mail" attribute if we give Primary SMTP as input. So i need Primary SMTP addresses for those mailboxes. That's why i started looking for a script which will pull Primary SMTP from displayNames. It would be really helpful if you can write an updated script for me. I will also search if any such script is available anywhere. Thanks again for your help and time. Cheers Frederick
April 30th, 2012 9:51pm

Thanks Mike for the reply, I should have given you more details :-) Actually i am in the process of working out OAB issues in our organization. Mail boxes will be skipped in the process of OAB generation when the "mail" attribute does not match with the Primary SMTP in proxyAddresses tab. I have a list of around 2000 mailboxes which have such issues, Mail attribute not matching the primary SMTP. I have only the displayNames of those mailboxes with me. I have a vbscript which will modify the "mail" attribute if we give Primary SMTP as input. So i need Primary SMTP addresses for those mailboxes. That's why i started looking for a script which will pull Primary SMTP from displayNames. It would be really helpful if you can write an updated script for me. I will also search if any such script is available anywhere. Thanks again for your help and time. Cheers Frederick
Free Windows Admin Tool Kit Click here and download it now
April 30th, 2012 9:51pm

Hey, we're in luck. The quest cmdlets know a little about Exchange! Get-Content C:\UserList.txt | Get-QADUser | ft displayname, samaccountname, PrimarySMTPAddress Mike Crowley | MVP My Blog -- Planet Technologies
April 30th, 2012 10:38pm

Hi Mike, Thank you for the Solution, You have just saved a lot of my time. You are simply superb. I have downloaded and ran the Quest cmdlets given by you and it worked very well !!!! I have exported the desired result like below: Get-Content C:\UserList.txt | Get-QADUser | select samaccountname, PrimarySMTPAddress | Export-Csv -notype c:\output.csv Thanks again for everything. Take Care. Frederick
Free Windows Admin Tool Kit Click here and download it now
May 1st, 2012 1:29am

Hi Mike, Thank you for the Solution, You have just saved a lot of my time. You are simply superb. I have downloaded and ran the Quest cmdlets given by you and it worked very well !!!! I have exported the desired result like below: Get-Content C:\UserList.txt | Get-QADUser | select samaccountname, PrimarySMTPAddress | Export-Csv -notype c:\output.csv Thanks again for everything. Take Care. Frederick
May 1st, 2012 1:29am

Hi Mike, I have another issue. I have a .csv file which has a list of CNs and their corresponding email addresses (Mail Attribute). I am trying to update these email addresses as Primary SMTP of those objects as these objects are either missing/ having invalid Primary SMTP addresses. I am using the script as below: Get-Content .\proxyadd.csv | ForEach-Object {$flds = $_.split("`t");Get-QADUser $flds[0] | Add-QADProxyAddress -Address $flds[1] -Primary:$true} But i am getting an error message saying that it cannot validate argument on Parameter "Address" Please guide me with this or if you have any other way of updating the Primary SMTP with the list of CNs and email addresses
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2012 7:11am

Hi Mike, I have another issue. I have a .csv file which has a list of CNs and their corresponding email addresses (Mail Attribute). I am trying to update these email addresses as Primary SMTP of those objects as these objects are either missing/ having invalid Primary SMTP addresses. I am using the script as below: Get-Content .\proxyadd.csv | ForEach-Object {$flds = $_.split("`t");Get-QADUser $flds[0] | Add-QADProxyAddress -Address $flds[1] -Primary:$true} But i am getting an error message saying that it cannot validate argument on Parameter "Address" Please guide me with this or if you have any other way of updating the Primary SMTP with the list of CNs and email addresses
May 6th, 2012 7:11am

use import-csv, not get-content. Then you can map the column headers in the csv (make sure you have column headers) to the values you want. Mike Crowley | MVP My Blog -- Planet Technologies
Free Windows Admin Tool Kit Click here and download it now
May 15th, 2012 11:31pm

use import-csv, not get-content. Then you can map the column headers in the csv (make sure you have column headers) to the values you want. Mike Crowley | MVP My Blog -- Planet Technologies
May 15th, 2012 11:41pm

Mike, is it possible to do the same thing, only search by surname, givenname instead of displayname?
Free Windows Admin Tool Kit Click here and download it now
July 11th, 2012 4:48pm

So you mean instead of one attribute, two? In my experience, people are less strict when changing a surname or given name, so be careful of bob/robert and surname changes, etc. Perhaps more importantly, these attributes are not unique. If you have a CSV of users, such as: surname,givenname Mike,Crowley Jorge,Diaz and were using the above-mentioned Quest PowerShell cmdlets, it would look like this (assumming you want the same output as Frederick: Import-Csv C:\userlist.csv | % {Get-QADUser -First $_.givenname -LastName $_.surname} | ft displayname, samaccountname, PrimarySMTPAddress Mike Crowley | MVP My Blog -- Planet Technologies
July 12th, 2012 12:00am

Thanks Mike, I do understand the limitations. I've been tasked with taking a list of users (lastname, firstname, MI) and returning their email addresses. Unfortunately when I run your command, it seems to only be returning user's email addresses from my immediate domain, but this is a GAL-wide request that spans 7 domains. Is there a way to change the scope? I tried adding the -searchroot paramater but when I enter the domain name in canonical i.e. domain.com it gives me an error of "ambiguous identity" Ok, I switched to using the distringuished name (which I also found DC, OU, etc to be case sensitive), and it seems to resolve but doesn't return any names... :( I take it the searchroot or at least searchscope paramater will not traverse sub-domains?
Free Windows Admin Tool Kit Click here and download it now
July 12th, 2012 9:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics