Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function User-creation-cycle {
- switch ($OU)
- {
- {$_ -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" }
- {$_ -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" }
- 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" }
- }
- Write-Host "User created at " -NoNewline; Write-Host "$OU" -ForegroundColor red -BackgroundColor white;
- echo " " >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "----------------------------------------------" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "Display name: $name $lastname" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "Username: $sam" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "Password: $pwd_plain" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "Extention: $extention"
- Write-Host "SMTP address: " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " not exists";
- Write-Host "Enabling mailbox with " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " as main smtp address"
- Write-Host " "
- [void](Enable-Mailbox -Identity "$sam@xforex.com" -Database DB1 -Alias $sam -DomainController il-dc1.idi.local -Force)
- echo "Email: $sam@xtrade.com" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- echo "User created in $OU" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- #Check if online migration needed
- switch ($online_mailbox)
- {
- {$_ -like 'TRUE'} {
- echo "Mailbox $sam@xtrade.com will be transferred to Office 365. See your email for update" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- 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"
- echo " "
- $online_migrate_users | Add-Member -MemberType Noteproperty -name Emailaddress -Value "$sam@xtrade.com"
- }
- {$_ -like 'FALSE'} {
- echo "Mailbox $sam@xtrade.com will be created on local Exchange server" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- Write-Host "Mailbox " -NoNewline; Write-Host "$sam@xtrade.com" -ForegroundColor red -BackgroundColor white -NoNewline; Write-Host " will be created on local Exchange server";
- echo " "
- }
- default {
- echo "Mailbox $sam@xtrade.com will be created on local Exchange server" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- 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";
- }
- }
- #Check if online license needed
- switch ($online_license)
- {
- {$_ -like 'TRUE'} {
- $online_license_users | Add-Member -MemberType Noteproperty -name Name -Value "$name $lastname"
- Write-Host $name $lastname -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " license will be added"
- echo "$name $lastname Office365 license will be added" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- }
- {$_ -like 'FALSE'} {
- Write-Host $name $lastname -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " created with no Office 365 license"
- echo "$name $lastname created with no Office365 license" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- }
- default {
- Write-Host $name -ForegroundColor red -BackgroundColor white -NoNewLine; Write-Host " created with no Office 365 license"
- echo "$name $lastname created with no Office365 license" >> \\fs01\IT\user-mgmt\new\log\$filename.log
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement