Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function New-Employee
- {
- do {$UserOU = Read-Host 'User belongs in which site: CA NJ or NY?'}
- while (($UserOU -ne 'CA') -and ($UserOU -ne 'NJ') -and ($UserOU -ne 'NY'))
- (($UserOU -eq 'CA') -or ($UserOU -eq 'NJ') -or ($UserOU -eq 'NY'))
- $OUPath = 'OU=Users,OU='+$UserOU+',OU=Tenehawk,DC=tenehawk,DC=local'
- Write-Host 'The path the user will be placed in is' $OUPath
- $fname = Read-Host 'First name'
- $lname = Read-Host 'Last name'
- $displayname = $fname + ' ' + $lname
- $upn = Read-Host 'Username'
- Write-host 'Display Name:' $displayname
- New-ADUser -SamAccountName $upn -GivenName $fname -Surname $lname -Name $displayname -Displayname $displayname -AccountPassword (Read-Host "Password" -AsSecureString) -Path $OUPath
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement