Advertisement
Guest User

checkthis

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