|
Replies:
14
-
Pages:
1
-
Last Post:
Nov 23, 2008 12:41 PM
by: Macasauras
|
|
|
Posts:
8
Registered:
1/20/08
|
|
|
|
Mail Enabled Contacts in W2K3
Posted:
Jan 21, 2008 10:39 PM
|
|
|
I need to create a script to create a ton of mail enabled contacts in AD. I am very new when it comes to scripting so I could use some help. I saw the script for creating multiple test users and was able to tweak it to create contacts but I can't figure out how to mail enable them. Any pointers would be greatly appreciated. Thanks.
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 22, 2008 2:48 AM
in response to: powellmap@gmail...
|
|
|
Which version of Exchange do you have? 2003?
The process is different for 2003 and 2007. In 2003 you mail-enable users and have RUS do the rest - so AD cmdlets are your friends. In 2007 you should use Exchange 2007 cmdlets because the RUS is not there.
Dmitry
See also: Dmitry's PowerBlog at http://dmitrysotnikov.wordpress.com
|
|
|
Posts:
8
Registered:
1/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 22, 2008 2:22 PM
in response to: Dmitry Sotnikov
|
|
|
I am using Exchange 2003. Is there a difference in the way you mail enabled user and mail enabled contacts?
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 23, 2008 3:08 AM
in response to: powellmap@gmail...
|
|
|
I think that for mail-enabled users you only need to set the mail attribute and RUS will do the rest (for mailbox-enabled users you will obviously need more).
So something like the following should do the trick (I don't have an Exchange 2003 lab at my disposal right now so I cannot check the code):
New-QADUser -ParentContainer mydomain.local/test -Name "Abc Xyz" -samAccountName "abcxyz" -UserPassword "P@ssword" -ObjectAttributes @{mail='abc.xyz@mydomain.com'} | Enable-QADUser
Dmitry
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 23, 2008 3:38 AM
in response to: Dmitry Sotnikov
|
|
|
A colleague of mine just told me that as far as he knows the following attributes need to be set (again, I cannot verify this in a lab right now):
For mail-enabled you probably need targetAddress & mailNickname. For mailbox-enabled, set: - mail - mailNicknamе - legacyExchangeDN - msExchHomeServerName - homeMDB - homeMTA
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 23, 2008 3:51 AM
in response to: Dmitry Sotnikov
|
|
|
My bad, you were actually asking about contacts :)
New-QADObject -Type Contact -ParentContainer mydomain.local/test -Name "Test Contact" -DisplayName "Test Contact" -ObjectAttributes @{mailNickname='abcxyz', targetAddress='abc.xyz@mydomain.com', systemFlags=1610612736}
I hope you have a lab to verify and tweak the command.
|
|
|
Posts:
8
Registered:
1/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 24, 2008 12:27 PM
in response to: Dmitry Sotnikov
|
|
|
Dmitry - thanks for the example. Unfortunately I am not having any success creating the contacts mail enabled. The script will not run unless I specify a type for the -ObjectAttributes. Also, the script has one error in it.
New-QADObject -Type Contact -ParentContainer mydomain.local/test -Name"Test Contact" -DisplayName "Test Contact" -ObjectAttributes @{mailNickname='abcxyz',(the commas should be ;) targetAddress='abc.xyz@mydomain.com', systemFlags=1610612736}
If I replace the commas with ; and add a type to the -ObjectAttributes it completes without errors but the Contact is created without any of the -ObjectAttribute properties set. Running the following script produces the same result as running the one above.
New-QADObject -Type Contact -ParentContainer mydomain.local/test -Name"Test Contact" -DisplayName "Test Contact"
I am continuing to play around with it. Let me know if anything stands out for you as to why the ObjectAttribute properties are not being created. Thanks again.
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 25, 2008 7:39 AM
in response to: powellmap@gmail...
|
|
|
It looks like it also needs legacyEchangeDN and mAPIRecipient.
Andrei Moiseev told me that the following seems to be working for him:
New-QADObject -Type Contact -ParentContainermydomain.local/test -Name "Test Contact" -DisplayName "TestContact" Set-QADObject "Test Contact"-ObjectAttributes @{ mailNickname ='TestContact'; targetAddress='SMTP:testcontact@testenv.msk.lab'; legacyExchangeDN='/o=FirstOrganization/ou=First Administrative Group/cn=Recipients/cn=TestContact';mAPIRecipient = $false }
|
|
|
Posts:
8
Registered:
1/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 25, 2008 12:20 PM
in response to: Dmitry Sotnikov
|
|
|
Thanks for the update. Both scripts work great when ran alone. If I try to combine them I get an error. Is that just a limitation and each script needs to be run alone. For example I run the script to create the contact and then I run the script to add the atrributes. It works fine that way. I am working on modifying the scripts to create a huge set of test contacts as well. Thanks again for your help.
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 25, 2008 12:27 PM
in response to: powellmap@gmail...
|
|
|
Frankly, I don't know. It might well indeed be a limitation of the way AD and Exch 2003 work, and require the object to be created first and then get the attribute. I just don't have the lab do the tests myself and so I was happy to stop the experiments once Andrey confirmed success.
|
|
|
Posts:
8
Registered:
1/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Jan 30, 2008 3:42 PM
in response to: Dmitry Sotnikov
|
|
|
Dmitry thanks so much for all your help. I needed these scripts to help test an issue at work and these were a huge help. I had to create 18k users / 79k mail enabled contacts. I finally got everything created and working properly. I have included my final scripts for anyone who is interested. Thanks again.
CreateUsers 16001..18000| ForEach-Object { New-QADUser-ParentContainer powellmedia.local/testusers8 -Name “testuseracct$_“-SamAccountName “testuseracct$_“ -UserPrincipalName“testuseracct$_@powellmedia.com“ -FirstName “testUseracct$_“ -LastName“example$_“ -UserPassword “password_123“} Note: This script doesn’t enable the users. I had issues using the Enable cmd in this contact. It was really a non issue. CreateContacts 10009..10009| ForEach-Object { New-QADObject-Type Contact -ParentContainer powellmedia.local/testcontacts1 -Name"TestContact$_" -DisplayName "TestContact$_"} EnableContactswithAttributes 10009..10009| ForEach-Object { Set-QADObject"TestContact$_" -ObjectAttributes @{mailNickname="testcontact"+$_; legacyExchangeDN="/o=FirstOrganization/ou=First AdministrativeGroup/cn=Recipients/cn=TestContact"+$_ ;mAPIRecipient = $false;mail="testcontact"+$_+"@gmail.com" ;targetaddress="SMTP:testcontact"+$_+"@gmail.com"}}
|
|
|
Posts:
1,151
Registered:
12/1/06
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Feb 8, 2008 7:36 AM
in response to: powellmap@gmail...
|
|
|
Cool! Glad that it worked. You could actually make these true one-liners by using pipeline to enable user accounts (New-QADUser | Enable-QADUser) and set the attributes for the contacts (New-QADObject | Set-QADObject) but that's just a perfectionist in me. One line or two lines of PowerShell code, who cares? It would have been 50 in VBScript. ;)
|
|
|
Posts:
2
Registered:
11/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Nov 20, 2008 9:01 PM
in response to: Dmitry Sotnikov
|
|
|
Hi,
I am trying to mail enable abou 1000 contacts in active directory.
The Power Shell commands I have tried to use is:
$UserDetails=Import-Csv “ImportedUsersforExchange.csv” foreach($DN in $UserDetails) {Set-QADObject $dn -ObjectAttributes @{mailNickname=$mailNickname; legacyExchangeDN=$legacyExchangeDN ;mAPIRecipient =$false ;mail=$mail ;targetaddress=$targetaddress}}
I keep getting errors like this: Set-QADObject : A parameter cannot be found that matches parameter name '@{DN=CN=**** *****,OU=Contacts,DC=Internal, DC=*****,DC=com; (the stars are personal data that I have taken out. Note, this line continues with all the data in the CSV file for this user). At line:1 char:44
I get out put like this for every user in the CSV file.
I'm using 2003 server with Exch 2003.
The headings I have in the CSV file are: DN,objectClass,displayName,name,cn,givenName,sn,initials,title,department,company,streetAddress,l,st,c,postalCode,mail,proxyAddresses,targetAddress,mAPIRecipient,mailNickname,showInAddressBook,legacyExchangeDN,telephoneNumber,otherTelephone,homePhone,mobile,facsimileTelephoneNumber,wWWHomePage,info I have got this CSV file by doing an export using CSVDE.
Any ideas of what's wrong here? Its as though the file doesn't contain the DN values, but it does. I have tried using other variables in place of the DN, and it give output indicating there is no data there.
Thanks for you help!
|
|
|
Posts:
1,919
Registered:
1/31/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Nov 22, 2008 4:55 AM
in response to: Macasauras
|
|
|
You need to reference all occurrences of $DN with the corresponding property name (csv column name):
$UserDetails=Import-Csv “ImportedUsersforExchange.csv” foreach($DN in $UserDetails) {Set-QADObject $dn.dn -ObjectAttributes @{mailNickname=$dn.mailNickname; legacyExchangeDN=$dn.legacyExchangeDN ;mAPIRecipient =$false ;mail=$dn.mail ;targetaddress=$dn.targetaddress}}
In a pipline command you reference the current piped object using $_, as in:
Import-Csv ImportedUsersforExchange.csv | foreach { Set-QADObject $_.dn -ObjectAttributes @{mailNickname=$_.mailNickname; legacyExchangeDN=$_.legacyExchangeDN ;mAPIRecipient =$false ;mail=$_.mail ;targetaddress=$_.targetaddress }
|
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
|
|
Posts:
2
Registered:
11/20/08
|
|
|
|
Re: Mail Enabled Contacts in W2K3
Posted:
Nov 23, 2008 12:41 PM
in response to: Shay Levy
|
|
|
Thanks for your help, Shay. Made your suggested changes and that worked first time. You wouldn't believe how long this noob had spent banging his head against the wall on this! Fantastic!
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|