header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
User creation/Provision with email
Last Post 29 May 2009 08:15 AM by G4meDTP. 2 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
G4meDTPUser is Offline
New Member
New Member
Posts:34
Avatar

--
29 May 2009 08:05 AM
    This is a place holder so I can use Quick Reply where the < code > tags work.
    G4meDTPUser is Offline
    New Member
    New Member
    Posts:34
    Avatar

    --
    29 May 2009 08:07 AM
    Delete
    G4meDTPUser is Offline
    New Member
    New Member
    Posts:34
    Avatar

    --
    29 May 2009 08:15 AM
    Below is a PS (with QAD) script that works fine to create a user account, place it in a particular OU, set some properties, add it to a couple of groups, create the mailbox (Exch07), and finally set the password to never expire. <BR><BR>All of the examples I found on the web were larger and more complex (see the 4-part Technet series). I find this to be easier to understand for a non-programmer.<BR><BR>The problem with this script (besides no error correction) is that I am calling the source CSV 4 times. I am certain that there is a cleaner way to do this. Some way to gather the CSV file data into memory and then parse it repeatedly as needed. <BR><BR>Any input is appreciated.<BR>Thanks. <BR><BR>
    # 5/27/09 # This works. #Problems - # Pops an error for each user created, but works. "-ErrorAction SilentContinue" does not resolve. #Need to do - # fix Errors. # Error handling #Notes # Why use "new-QADUser" instead of "New-Mailbox"? - New-QADUser exposes more AD User Object attributes for modification. e.g. '-description' & '-Company' # Why the "Start-Sleep -Seconds 3" statement? - Active Directory (AD) is 'slow', so this needs to wait 'forever' before starting to create the mailbox, or you get an error. # The password is pulled from the CSV and different for each user, so no "-AsSecureString" like many of the examples on the web. # Compare this code to the 4-part series on this at http://technet.microsoft.com/en-us/...shell.aspx # And that code is still a mess. ################################################## # Variables ################################################## $Dom = [ADSI] "LDAP://dc=MyDomain,dc=local" $HomeOU = 'OU=MyOU,DC=MyDomain,dc=local' $CSVfile = 'C:\aaaa\MyCSV.csv' $group1 = "CN=ThirdOU,OU=SecondOU,OU=FirstOU,DC=MyDomain,DC=local" $group2 = "CN=ThirdOtherOU,OU=SecondOU,OU=FirstOU,DC=MyDomain,DC=local" ################################################## #User Creation from the CSV ################################################## Import-Csv $CSVfile |` where {New-QADUser -ParentContainer $HomeOU -name ($_.givenName + " " + $_.sn) -SamAccountName $_.sAMAccountName -LastName $_.sn ` -UserPassword $_.password -Company "My Comapny" -FirstName $_.givenName -Description "My Description" ` -DisplayName ($_.givenName + " " + $_.sn) } ################################################## #Recall the CSV and add the users to the group. ################################################## Import-Csv $CSVfile | foreach { $users = $_.samAccountName Add-Qadgroupmember -identity $group1 -Member $users Add-Qadgroupmember -identity $group2 -Member $users } Start-Sleep -Seconds 3 ################################################## #Recall the CSV and Create the Mailboxes ################################################## Import-Csv $CSVfile | where {Enable-Mailbox -Database "EmailServer\SG01\DB01" -Identity ("DC4\" + "\" + $_.samAccountName) } ################################################## #Recall the CSV and set password not to expire. ################################################## Import-Csv $CSVfile | foreach { $users = $_.samAccountName Set-QADUser -Identity $users -PasswordNeverExpires $true }
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer