Advertisement
Guest User

Untitled

a guest
May 8th, 2018
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. while($true){
  2.    
  3.  
  4. Copy-Item -Path "\\int.zero.com\zero\org\ICT\zero\SD\PS-Modules\Write-Ascii" -Destination "C:\Users\$Env:UserName\Documents\WindowsPowerShell\Modules\Write-Ascii" -Recurse -Force
  5. Import-Module Write-Ascii
  6. Write-Ascii -fore white "ZERO"
  7. Write-Ascii -fore red "ZERO"
  8. Write-Ascii -fore rainbow "version 3"
  9.  
  10.  
  11. write-host -ForegroundColor Red "Goodmorning $Env:UserName"
  12.  
  13. $ErrorActionPreference = "SilentlyContinue"
  14.  
  15. #input prompts
  16. $initials    = Read-Host 'VOORLETTERS'
  17. $Firstname   = Read-Host 'VOORNAAM'
  18. $Lastname    = Read-Host 'ACHTERNAAM'
  19. $UserID      = Read-Host 'GEBRUIKERSNAAM'
  20. $Alias2       = Read-Host 'ALIAS VOOR E-MAIL'
  21. $department  = Read-Host 'AFDELING'
  22. $title       = Read-Host 'FUNCTIE'
  23. $description = Read-Host 'PERSONEELSNUMMER'
  24. $OUPath      = Read-Host 'INTERN/EXTERN'
  25.  
  26. #static variables
  27. $Password     = (ConvertTo-SecureString -AsPlainText 'Welcome01' -Force)
  28. $Displayname  = "$lastname, $initials"
  29. #$OUPath       = 'OU=Intern,OU=Gebruikers,OU=ZERO,DC=int,DC=zero,DC=com'
  30. #$OUPath2      = 'OU=Extern,OU=Gebruikers,OU=ZERO,DC=int,DC=zero,DC=com'
  31. $company      = 'ZERO'
  32. $profilePath  = "\\int.zero.com\Users\Profiles\$UserID"
  33. $OfficePhone  = '8888'
  34. $department   = "$department"
  35. $title        = "$title"
  36. $description  = "$description"
  37. $Name         = "$Firstname $Lastname"
  38. $initials     = "$initials"
  39.  
  40. $OUPathValidate = $false
  41. While ($OUPathValidate) {
  42.    
  43.     If ($OUPath.ToUpper() -eq 'INTERN') {
  44.         $OUPath = 'OU=Intern,OU=Users,OU=ZERO,DC=int,DC=rpz,DC=com'
  45.         $OUPathValidate = $true
  46.     } ElseIf ($OUPath.ToUpper() -eq 'EXTERN') {
  47.         $OUPath = 'OU=Extern,OU=Users,OU=ZERO,DC=int,DC=rpz,DC=com'
  48.         $OUPathValidate = $true
  49.     } Else {
  50.         Write-Host 'That is not a valid input, please use INTER or EXTERN'
  51.     }
  52. }
  53.  
  54.  
  55. #used to add parameters
  56. $Parameters = @{
  57.     'SamAccountName'        = $UserID
  58.     'UserPrincipalName'     = $UserID
  59.     'Name'                  = "$Firstname $initials $Lastname"
  60.     'GivenName'             = $Firstname
  61.     'Surname'               = $Lastname
  62.     'DisplayName'           = $Displayname
  63.     'AccountPassword'       = $password
  64.     'ChangePasswordAtLogon' = $true
  65.     'Enabled'               = $true
  66.     'Path'                  = $OUPath
  67.     'company'               = $company
  68.     'department'            = $department
  69.     'description'           = $description
  70.     'title'                 = $title
  71.     'profilePath'           = $profilePath
  72.     'initials'              = $initials
  73.     'OfficePhone'           = $OfficePhone
  74.    
  75.  
  76.    
  77. }
  78.  
  79. #used to add groupmembers to new users
  80. import-module activedirectory
  81. New-ADUser @Parameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement