Disclaimer: We hope that the information on these pages is valuable to you.
Your use of the information contained in these pages, however, is at your sole risk.
All information on these pages is provided "as -is", without any warranty, whether express or implied,
of its accuracy, completeness, fitness for a particular purpose, title or non-infringement,
and none of the third-party products or information mentioned in the work are authored, recommended, supported or guaranteed by site owners or operators.
Further, the site owners and operators shall not be liable for any damages you may sustain by using this information,
whether direct, indirect, special, incidental or consequential, even if it has been advised of the possibility of such damages.
Warning: main(/home/prosphot/public_html/smog/track/write_logs.php) [function.main]: failed to open stream: No such file or directory in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Warning: main(/home/prosphot/public_html/smog/track/write_logs.php) [function.main]: failed to open stream: No such file or directory in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Warning: main() [function.include]: Failed opening '/home/prosphot/public_html/smog/track/write_logs.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/prosphot/public_html/blog/skins/leaf/footer.php on line 3
Tue 07.29.08: New users script.
We wanted to automate the process of creating new Exchange users. Because you can't create mailboxes using AD users and computers, we did not want to have to instruct everyone on how to use the new tools.So we set-up a script that runs every day and takes all the users in an OU that are not mail enabled and then we mail enable them. (We ONLY wanted the ones in the parent OU, not the sub OUs. Our contractors and terminated employees are in sub OUs).
Here is the script:
$a = get-user -OrganizationalUnit "[REMOVED]/Corp/Users" -RecipientTypeDetails "User" | where {$_.DistinguishedName -notlike '*OU=Generic Accounts,OU=Employees,OU=Users,OU=Corp,DC=[REMOVED],DC=int' -and $_.DistinguishedName -notlike '*OU=Contractors,OU=Employees,OU=Users,OU=Corp,DC=[REMOVED],DC=int'}
remove-item d:\scripts\newusers.txt
$date = get-date
Add-Content d:\scripts\newusers.txt "=============================================="
Add-Content d:\scripts\newusers.txt "Starting New User Mailbox Run"
Add-Content d:\scripts\newusers.txt " "
foreach ($item in $a) {
Add-Content d:\scripts\newusers.txt "Creating Mailbox for: $item"
Add-Content d:\scripts\newusers.txt " "
enable-mailbox -Identity $item -Alias $item.SamAccountName -Database "EX01\TempSG1\TempSG1-MS1"
}
Add-Content d:\scripts\newusers.txt "Finished New User Mailbox Run"
Add-Content d:\scripts\newusers.txt "=============================================="
Add-Content d:\scripts\newusers.txt "Users in the TempSG1-MS1 Mail Database"
Add-Content d:\scripts\newusers.txt "SamAccountName (Department) WindowsEmailAddress "
Add-Content d:\scripts\newusers.txt " "
$b = get-mailbox -Database "EX01\TempSG1\TempSG1-MS1"
foreach ($itemb in $b) {
$userdata = get-user $itemb
$userdatastring = $userdata.SamAccountName + " (" + $userdata.Department + ") " + $userdata.WindowsEmailAddress
Add-Content d:\scripts\newusers.txt $userdatastring
Add-Content d:\scripts\newusers.txt " "
}
Add-Content d:\scripts\newusers.txt "=============================================="
Add-Content d:\scripts\newusers.txt "Script Finished"
-----------------------------------------------
Because we add them to a temporary mail store, we then generate a list that shows us what department they user belongs to. Then we can move them to the correct mail store (we base mail store membership on department) the following week.
Item Rating Information....