Advertisement
Guest User

Untitled

a guest
Feb 10th, 2016
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. Import-Module ActiveDirectory -ErrorAction SilentlyContinue
  2. Do{
  3. Write-Host "********************************************************************"
  4. Write-Host "** New User Creation Script **"
  5. Write-Host "********************************************************************"
  6.  
  7. #----------------------------------------------------------
  8. #
  9. #Ask for the information required for the new UserAccount
  10. #----------------------------------------------------------
  11.  
  12. $FirstName = Read-Host "Enter users's First Name"
  13. $LastName = Read-Host "Enter user's Last Name"
  14. $UserName = Read-Host "Enter user ID (ie - arasool)"
  15. $Password = Read-Host "Enter user's Password - Symbols are allowed"
  16. Write-Host "Checking if user already exists - Please give this time."
  17.  
  18. Start-Sleep -s 5
  19. #----------------------------------------------------------
  20. #
  21. #Check - Does this user already exist?
  22. #----------------------------------------------------------
  23. $Name = $UserName
  24. $User = Get-ADUser -Filter {sAMAccountName -eq $UserName}
  25. If ($User -eq $Null) {"User does not exist"} -ForegroundColor RED
  26. Else {$Answer -eq "User exists!";$x=1}
  27. }While($x -eq 0)
  28. Do{
  29. #EVERYTHING AFTER USER IS FOUND
  30. #GOES HERE
  31. $x=0
  32. #if you want to go back to start set x to 0 if you want to continue do x=2 and add another do-while loop
  33. }While($x -eq 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement