Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function User-creation-cycle {
  2.     switch ($OU)
  3.         {
  4.             {$_ -like '*KIEV*'} {New-Aduser "$name $lastname" -GivenName $name -AccountPassword $pwd -DisplayName "$name $lastname" -Description "RN: $Description" -Enabled $true -OfficePhone "$extention" -PasswordNeverExpires $true -Path $OU -SamAccountName $sam -Server il-dc1.idi.local -Surname $lastname -UserPrincipalName "$sam@xforex.com" }
  5.             {$_ -like '*Philippines*'} {New-Aduser "$name $lastname" -GivenName $name -AccountPassword $pwd -DisplayName "$name $lastname" -Description "RN: $Description" -Enabled $true -OfficePhone "$extention" -PasswordNeverExpires $true -Path $OU -SamAccountName $sam -Server il-dc1.idi.local -Surname $lastname -UserPrincipalName "$sam@xforex.com" }
  6.             default {New-Aduser "$name $lastname" -GivenName $name -AccountPassword $pwd -DisplayName "$name $lastname" -Description "RN: $Description" -Enabled $true -OfficePhone "$extention" -Path $OU -SamAccountName $sam -Server il-dc1.idi.local -Surname $lastname -UserPrincipalName "$sam@xforex.com" }
  7.         }
  8.     Write-Host "User created at " -NoNewline; Write-Host "$OU" -ForegroundColor red -BackgroundColor white;
  9.     echo " " >> \\fs01\IT\user-mgmt\new\log\$filename.log
  10.     echo "----------------------------------------------" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  11.     echo "Display name: $name $lastname" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  12.     echo "Username: $sam" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  13.     echo "Password: $pwd_plain" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  14.     echo "Extention: $extention"
  15.     Write-Host "SMTP address: " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " not exists";
  16.     Write-Host "Enabling mailbox with " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " as main smtp address"
  17.     Write-Host " "
  18.     [void](Enable-Mailbox -Identity "$sam@xforex.com" -Database DB1 -Alias $sam -DomainController il-dc1.idi.local -Force)
  19.     echo "Email: $sam@xtrade.com" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  20.     echo "User created in $OU" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  21.    
  22.     #Check if online migration needed
  23.     switch ($online_mailbox)
  24.         {
  25.             {$_ -like 'TRUE'} {
  26.                                 echo "Mailbox $sam@xtrade.com will be transferred to Office 365. See your email for update" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  27.                                 Write-Host "Mailbox " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " will be queued for transfering to Office 365"; Write-Host "Please see your email for update"
  28.                                 echo " "
  29.                                 $online_migrate_users | Add-Member -MemberType Noteproperty -name Emailaddress -Value "$sam@xtrade.com"
  30.                                 }
  31.             {$_ -like 'FALSE'} {
  32.                                 echo "Mailbox $sam@xtrade.com will be created on local Exchange server" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  33.                                 Write-Host "Mailbox " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " will be created on local Exchange server";
  34.                                 echo " "
  35.                                 }
  36.             default {
  37.                     echo "Mailbox $sam@xtrade.com will be created on local Exchange server" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  38.                     Write-Host "Mailbox type has not been specified"; Write-Host "Mailbox " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " will be created on local Exchange server";
  39.                     }
  40.         }
  41.     #Check if online license needed
  42.     switch ($online_license)
  43.         {
  44.             {$_ -like 'TRUE'} {
  45.                                 $online_license_users | Add-Member -MemberType Noteproperty -name Name -Value "$name $lastname"
  46.                                 Write-Host $name $lastname -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " license will be added"
  47.                                 echo "$name $lastname Office365 license will be added" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  48.                                 }
  49.             {$_ -like 'FALSE'} {
  50.                                 Write-Host $name $lastname -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " created with no Office 365 license"
  51.                                 echo "$name $lastname created with no Office365 license" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  52.                                 }
  53.             default {
  54.                     Write-Host $name -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " created with no Office 365 license"
  55.                     echo "$name $lastname created with no Office365 license" >> \\fs01\IT\user-mgmt\new\log\$filename.log
  56.                     }
  57.            
  58.         }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement