Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while($true){
- 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
- Import-Module Write-Ascii
- Write-Ascii -fore white "ZERO"
- Write-Ascii -fore red "ZERO"
- Write-Ascii -fore rainbow "version 3"
- write-host -ForegroundColor Red "Goodmorning $Env:UserName"
- $ErrorActionPreference = "SilentlyContinue"
- #input prompts
- $initials = Read-Host 'VOORLETTERS'
- $Firstname = Read-Host 'VOORNAAM'
- $Lastname = Read-Host 'ACHTERNAAM'
- $UserID = Read-Host 'GEBRUIKERSNAAM'
- $Alias2 = Read-Host 'ALIAS VOOR E-MAIL'
- $department = Read-Host 'AFDELING'
- $title = Read-Host 'FUNCTIE'
- $description = Read-Host 'PERSONEELSNUMMER'
- $OUPath = Read-Host 'INTERN/EXTERN'
- #static variables
- $Password = (ConvertTo-SecureString -AsPlainText 'Welcome01' -Force)
- $Displayname = "$lastname, $initials"
- #$OUPath = 'OU=Intern,OU=Gebruikers,OU=ZERO,DC=int,DC=zero,DC=com'
- #$OUPath2 = 'OU=Extern,OU=Gebruikers,OU=ZERO,DC=int,DC=zero,DC=com'
- $company = 'ZERO'
- $profilePath = "\\int.zero.com\Users\Profiles\$UserID"
- $OfficePhone = '8888'
- $department = "$department"
- $title = "$title"
- $description = "$description"
- $Name = "$Firstname $Lastname"
- $initials = "$initials"
- $OUPathValidate = $false
- While ($OUPathValidate) {
- If ($OUPath.ToUpper() -eq 'INTERN') {
- $OUPath = 'OU=Intern,OU=Users,OU=ZERO,DC=int,DC=rpz,DC=com'
- $OUPathValidate = $true
- } ElseIf ($OUPath.ToUpper() -eq 'EXTERN') {
- $OUPath = 'OU=Extern,OU=Users,OU=ZERO,DC=int,DC=rpz,DC=com'
- $OUPathValidate = $true
- } Else {
- Write-Host 'That is not a valid input, please use INTER or EXTERN'
- }
- }
- #used to add parameters
- $Parameters = @{
- 'SamAccountName' = $UserID
- 'UserPrincipalName' = $UserID
- 'Name' = "$Firstname $initials $Lastname"
- 'GivenName' = $Firstname
- 'Surname' = $Lastname
- 'DisplayName' = $Displayname
- 'AccountPassword' = $password
- 'ChangePasswordAtLogon' = $true
- 'Enabled' = $true
- 'Path' = $OUPath
- 'company' = $company
- 'department' = $department
- 'description' = $description
- 'title' = $title
- 'profilePath' = $profilePath
- 'initials' = $initials
- 'OfficePhone' = $OfficePhone
- }
- #used to add groupmembers to new users
- import-module activedirectory
- New-ADUser @Parameters
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement