Powershell_script_fuction_and_error_handling

advertisement
Important: Valid user ID format must have 5 or 6 numeric characters when read from right to left.
Example ADC12345, C12345 or ADC123456. Any ID which has less than 5 or greater than 6 numeric
characters from right to left ,is an invalid user ID format. Example ADC1234, C123, or ADC1234567.
Script Function with error handling:
1. Enter User ID:
2. If invalid user ID is entered, a warning should be presented “User ID format is incorrect. Please
enter correct user ID”. Should loop back until user enters valid ID.
3. If valid ID entered, user is presented with the next input field - “Is user VIP?” Type Y or N:
4. After typing Y or N, display message on next line “You have specified the user is a non-VIP user”
if N was typed in step 2 or “You have specified the user is a VIP user” if Y was typed in step 2
5. Mod 2 calculation on the numeric value of user ID occurs to determine if user is to be added to
AppPG1 or AppPG2 AD group. If mod 2 result of user ID numeric value = 1, then add user to
AppPG1. If mod 2 result of user ID numeric value = 0, then add user to AppPG2.
6. Display outcome as “The user will be added to AppPG1” (if mod 2 result is 1) or “The user will be
added to AppPG2” (if mod 2 result is 0).
 Based on the mod 2 result =1, user should be in AppPG1 group. If user exists already in
AppPG2, this means user is already in an incorrect group. At this point the script should
not add the user to the correct group “AppPG1” but should display message “User exist
in an incorrect group. “show incorrect AD group name here””
 Based on the mod 2 result =1, user should be in AppPG1 group. If user already exist in
the correct group “AppPG1”, display message “The user is already a member of the
“Correct AD group here””
7. Mod 4 calculations on the numeric value of user ID occurs to determine if user is to be added to
XD_HOME_XDS_01 or XD_HOME_XDS_02 AD group. If mod 4 result of user ID numeric value = 0
or 1, then add user to XD_HOME_XDS_01. If mod 4 result of user ID numeric value = 2 or 3, then
add user to XD_HOME_XDS_02.
8. Display outcome as “The user will now be added to XD_HOME_XDS_01” (if mod 4 result is 0 or
1) OR “The user will be added to XD_HOME_XDS_02” (if mod 4 result is 2 or 3).
 Based on the mod 4 result = 0 or 1, user should be in XD_HOME_XDS_01 group. If user
exists already in XD_HOME_XDS_02, this means user is already in an incorrect group. At
this point the script should not add the user to the correct group “XD_HOME_XDS_01”
but should display message “User exist in an incorrect group. “show incorrect AD group
name here””.
 Based on the mod 4 result = 0 or 1, user should be in XD_HOME_XDS_01 group. If user
already exists in the correct group “XD_HOME_XDS_01”, displays message “The user is
already a member of the “Correct AD group here””.
9. Mod 4 calculation on the numeric value of user ID occurs to determine if non-VIP user is to be
added to either the
o Mod 4 result = 0 = "Admin_Userdata_Napphndc07av01_q" or
o Mod 4 result = 1 = "Admin_Userdata_Napphstc07av01_q" or
o Mod 4 result = 2 = "Admin_Userdata_Napphndc07bv01_q" or
o Mod 4 result = 3 ="Admin_Userdata_Napphstc07bv01_q"
OR
if VIP user to be added to either the
o Mod 4 result = 0 = "Admin_Userdata_Napphndc07av01_nq" or
o Mod 4 result = 1 = "Admin_Userdata_Napphstc07av01_nq" or
o Mod 4 result = 2 = "Admin_Userdata_Napphndc07bv01_nq" or
o Mod 4 result = 3 ="Admin_Userdata_Napphstc07bv01_nq"
10. Display outcome as “The user will be added to the “Correct AD group here”
 Based on the mod 4 result = 0 for a non-VIP user, the user should be in
“Admin_Userdata_Napphndc07av01_q” group. If user exists already in
“Admin_Userdata_Napphstc07av01_q” or any of the groups, this means user is already
in an incorrect group. At this point the script should not add the user to the correct
group “Admin_Userdata_Napphndc07av01_q” but should display message “User exist in
an incorrect group. “show incorrect AD group (s) name here””.
 Based on the mod 4 result = 0 for a non-VIP, user should be in
Admin_Userdata_Napphndc07av01_q group. If user already exists in the correct group
“Admin_Userdata_Napphndc07av01_q”, displays message “The user is already a
member of the “Correct AD group here””.
11. Create Output log file.
Download