James
 Basic Member Posts:374

 |
| 02 Dec 2009 06:08 AM |
|
Hello,
I have been asked to create some E-Mail accounts for some users which have been imported. They are teachers, other members of staff and also students. I am looking at basing this on a specific OU and then all the users who have Staff or Teacher as a Job Title in AD would need an acount creating. They will also need the tick from the Password Never Expires removing.
I can create the accounts in exchange this I can do and set the password to change the password at next logon. I can setup a generic password for them all and such.
What I require some help on is how do I read the job title field from AD and get a user one by one so I can create the mailbox and such and do this on a specific OU. Then I will need the check box clearing for Password Never Expires.
Could anyone please assist?
Many Thanks
James
|
|
|
|
|
Marco Shaw (MVP)
 Veteran Member Posts:1642

 |
| 02 Dec 2009 06:59 AM |
|
I'm not an AD pro. Are you able to use something like the Quest AD cmdlets? http://www.quest.com/powershell You should also check this out for a free AD ebook: http://www.quest.com/powershellbook |
|
Marco
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*Blog - http://marcoshaw.blogspot.com |
|
|
James
 Basic Member Posts:374

 |
| 02 Dec 2009 07:38 AM |
|
Hello,
Thank you for your response.
Unfortunatly I cant as I cant install that on the servers.
I would need to just use the windows powershell :(
Does anyone know how I can do this?
Many Thanks
James
|
|
|
|
|
Marco Shaw (MVP)
 Veteran Member Posts:1642

 |
| 02 Dec 2009 08:00 AM |
|
Check my 2nd link. There's an ebook that covers the basics also. A lot of AD stuff can be done directly from .NET. It just requires more code/experience (or lots of luck with Bing searching)... |
|
Marco
*Microsoft MVP - Windows PowerShell
https://mvp.support.microsoft.com/profile/Marco.Shaw
*Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
*Blog - http://marcoshaw.blogspot.com |
|
|
aleksandar
 New Member Posts:54

 |
| 02 Dec 2009 08:00 AM |
|
You don't need to install Quest AD cmdlets on the servers. An installation on admin machine is enough. |
|
| Follow me on Twitter: http://twitter.com/alexandair |
|
|
James
 Basic Member Posts:374

 |
| 03 Dec 2009 12:40 AM |
|
Oh right thanks :) I will check it out then :) I have now installed it onto my machine so I should be good to go :) I have also requested the ebook :) So within 14 days I should be good :) Many Thanks James |
|
|
|
|
James
 Basic Member Posts:374

 |
| 03 Dec 2009 02:07 AM |
|
Hello, I have the following attempt however I need some assistance. # Look in specific OU (For individual school) # Get the users from AD with a job Title of teacher OR Staff # Set PasswordNeverExpires to False # Match School in CSV # Create the mailbox based on the mailbox location from CSV Import-Csv -Path "C:\TestEMail.csv" | ForEach-Object { $Server = $_.ExchangeServer $StorageGroup = $_.StorageGroup $MailboxDatabase = $_.MailboxDatabase $Database = $Server + "\" + $StorageGroup + "\" + $MailboxDatabase $School = "schoolnamehere" #Change School name here Get-User -DomainController "DCNAMEHERE" -OrganizationalUnit "domain/OU/" + $School + "/ou2" Get-QADUser -Title "teacher" -or "staff" Set-QADUser -PasswordNeverExpires $false Write-Host "Creating Mailbox..." New-Mailbox -DisplayName $DisplayName -Password $secureString -Alias $Alias -FirstName $FirstName -LastName $LastName -Name $Name -OrganizationalUnit $OU -UserPrincipalName $PrincipalName -Database $Database } The top comments I hope to achieve however when I come to creating the mailbox I cant think how I can get the attributes from AD to create the mailbox. Does anyone know how I can do this? Many Thanks James |
|
|
|
|
James
 Basic Member Posts:374

 |
| 04 Dec 2009 12:40 AM |
|
Does anyone know how I can finish off my script? Many Thanks James |
|
|
|
|
James
 Basic Member Posts:374

 |
| 04 Dec 2009 02:12 AM |
|
Hello, I have installed the Quest stuff on the server now and its not finding the cmdlets :( I am trying to run the script on the server to see what errors I am getting. Does anyone know what I need to do? I have run it from the exchange management shell and windows Powershell Any suggestions? Many Thanks James |
|
|
|
|
James
 Basic Member Posts:374

 |
| 04 Dec 2009 02:13 AM |
|
Ok I have figured out I need to use the shell for the activroles... However Its not recognising Get user now??? Any suggestions on how I get around this? Many Thanks James |
|
|
|
|
Shay Levy PowerShell MVP, Admin
 Veteran Member Posts:1362

 |
|
James
 Basic Member Posts:374

 |
| 04 Dec 2009 03:37 AM |
|
Hello, Thanks for that Its going now however I am having some errors. I am being prompted for the Identity. I have the following which works ish.. # Look in specific OU (For individual school) # Get the users from AD with a job Title of teacher OR Staff # Set PasswordNeverExpires to False # Match School in CSV # Create the mailbox based on the mailbox location from CSV #Add-PSSnapin Quest.ActiveRoles.ADManagement Import-Csv -Path "C:\emaillists.csv" | ForEach-Object { $Server = $_.ExchangeServer $StorageGroup = $_.StorageGroup $MailboxDatabase = $_.MailboxDatabase $Database = $Server + "\" + $StorageGroup + "\" + $MailboxDatabase $School = "NAMEHERE" #Change School name here Get-QADUser -Title "teacher", "staff" -Identity "%username%" Set-QADUser -PasswordNeverExpires $false Get-User -DomainController "schdc1" -OrganizationalUnit "domainname/OU1/OU2/OU3" Get-LDAPUser "%username%","DCHERE" Write-Host "Creating Mailbox..." #New-Mailbox -DisplayName $DisplayName -Password $secureString -Alias $Alias -FirstName $FirstName -LastName $LastName -Name $Name -OrganizationalUnit $OU -UserPrincipalName $PrincipalName -Database $Database } If I run the Get-User on its own it returns fine.. If I run the Get-QADUser -Title "teacher", "staff" -Identity "%username%" it returns ok apart from it prompts for the Identity. If I take out the identity swith it works fine. Set-QADUser -PasswordNeverExpires $false works fine also. I would need it to get the teachers and staff within the OU and return the username and then change the property and create the mailbox. Does anyone have any idea's how I can do this? Many Thanks for your help its much appreciated. James |
|
|
|
|
James
 Basic Member Posts:374

 |
| 04 Dec 2009 07:36 AM |
|
Hello, I dont mean to push or anything however we are getting quite desperate to get these scripts sorted so that we can get the addresses and target addresses done. Once we can do this via a script then we can progress with the project which is due to go live next week early on. I hope someone can assist. Many Thanks for all help and support given so far and in the future. James |
|
|
|
|