
# Prompt for User Input
$User = Read-Host -Prompt 'Enter individual User ID. For example: abc123'
$FirstName = Read-Host 'Enter individual First Name.'
$MiddleInitial = Read-Host 'Enter individual Middle Initial'
$LastName = Read-Host 'Enter individual Last Name'
# Set Additional Variables
$DisplayName = "$FirstName $MiddleInitial $LastName"
# Create User Account
New-ADUser -Name "$DisplayName" `
-sAMAccountName $User `
-GivenName $FirstName `
-Surname $LastName `
-DisplayName "$DisplayName" `
-Initial $MiddleInitial `
-Description 'Staff' `
-UserPrincipalName "$User@domain.com" `
-ScriptPath 'Staff.bat' `
-HomeDrive 'Z:' `
-HomeDirectory "\\ServerName\$User$" `
-AccountPassword (Read-Host -AsSecureString "AccountPassword")
# Add User to Company-Wide Email Group
Add-ADGroupMember ALL_Company $User
# Optionally you can use the below parameter to require the individual to use a Smartcard. That will require the User ID be changed to the certificate name\number.
# Set-ADUser -Identity $User -SmartcardLogonRequired $true
# Optionally you can use the below parameter to require the individual to use a Smartcard. That will require the User ID be changed to the certificate name\number.
# Set-ADUser -Identity $User -SmartcardLogonRequired $true
No comments:
Post a Comment