Advertisement
Guest User

Untitled

a guest
May 25th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. # A script to ensure 100% accuracy and speed up the NS process, as well as enabling anyone to carry out the basic setup process
  2. #----------
  3. #Import the AD cmdlt
  4. Import-Module ActiveDirectory
  5. #----------
  6. #Define the New user and the permissions similar user as varibles via user imput
  7. $NewUser = Read-Host -Prompt 'Enter the New users firstname.lastname'
  8. $OldUser = Read-Host -Prompt 'Enter the permissions similar users firstname.lastname'
  9. #----------
  10. #Prompt to set the users password as a secure string (e.g **********)
  11. $newPassword = (Read-Host -Prompt "Provide New Password" -AsSecureString); Set-ADAccountPassword -Identity $NewUser -NewPassword $newPassword -Reset
  12. #----------
  13. #Creates a selection list with 6 options. Selection by typing a number and pressing enter
  14. [int]$xMenuChoiceA = 0
  15. while ( $xMenuChoiceA -lt 1 -or $xMenuChoiceA -gt 6 ){
  16. Write-host "1. UK"
  17. Write-host "2. International office"
  18. Write-host "3. Finance team"
  19. Write-host "4. Culture team"
  20. Write-host "5. IT Team"
  21. Write-host "6. Bored member"
  22. Write-host "7. Cancel"
  23. #----------
  24. #When an option is selected, what happens
  25. [Int]$xMenuChoiceA = read-host "Please enter an option 1 to 6..." }
  26. Switch( $xMenuChoiceA ){
  27. 1{Set-ADUser $NewUser –scriptPath “Windows7_LOGIN_SCRIPT.bat”}
  28. 2{Set-ADUser $NewUser –scriptPath “Windows7_LOGIN_SCRIPT_INT.bat”}
  29. 3{Set-ADUser $NewUser –scriptPath “Windows7_FINANCE_LOGIN_SCRIPT.bat”}
  30. 4{Set-ADUser $NewUser –scriptPath "Windows7_PEOPLE_LOGIN_SCRIPT”}
  31. 5{Set-ADUser $NewUser –scriptPath "Windows7_ITBC_LOGIN_SCRIPT.bat”}
  32. 6{Set-ADUser $NewUser –scriptPath "Windows7_Director_LOGIN_SCRIPT.bat”}
  33. 7{Write-host "No logon script set!"}
  34. }
  35. #----------
  36. #Sets the home drive to "P" and specifies the path. Also enables the account
  37. Set-ADUser $NewUser -HomeDrive "P:" -HomeDirectory "\\lime\private$\$Newuser" -Enabled $true
  38. #----------
  39. #Sets the "memberof" permissions for $NewUser to be the same as $Olduser and shows the output (-passthru)
  40. Get-ADUser $OldUser -Properties memberof | Select-Object -ExpandProperty memberof | Add-ADGroupMember -Members $NewUser -PassThru
  41. #----------
  42. #Prompts the user to press enter to finish the script run
  43. Read-Host -Prompt "Press Enter to exit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement