Team,
I need you help hopefull this is an easy one iam trying to create a single user account with script that uses input. Every time i run the script i am recieving an error for new-qaduser cmdlet see script below any help is appreciated. The first part i am using a visable input box. Thought that was the issue and switched to just read host and getting the same errros.
Add-PSSnapin quest.ActiveRoles.admanagement
#[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic') | Out-Null
#$employeeid = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Employee ID of User")
#$Username = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Username of User")
#$Firstname = [Microsoft.VisualBasic.Interaction]::InputBox("Enter First Name of User")
#$Lastname = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Last Name of User")
#$Title = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Users Title")
#$ExchangeDB = [Microsoft.VisualBasic.Interaction]::InputBox("Enter Exchange Database Example 'PARMBX01'")
[string]$employeeid = Read-Host "Enter Employee ID"
[string]$Username = Read-Host "Enter Username of User"
[string]$Firstname = Read-Host "Enter Firstname of User"
[string]$Lastname = Read-Host "Enter Lastname of User"
[string]$Title = Read-Host "Enter Title of User"
[string]$ExchangeDB = Read-Host "Enter Database of User 'parmbx00'"
[string]$Displayname = $Lastname+','+$Firstname
#Auto Generate User Password
$length = 8
$numberOfNonAlphanumericCharacters = 2
Add-Type -Assembly System.Web
$password = [Web.Security.Membership]::GeneratePassword($length,$numberOfNonAlphanumericCharacters)
#Default Organizational Unit
[string]$Path = "ou=users,dc=domain.com"
#User Account Creation
Write-Host "Creating User Object"
New-QADUser -Name $Displayname -ParentContainer $Path -FirstName $Firstname -LastName $Lastname -Description $Title -ObjectAttributes @{employeeID = $employeeid} -SamAccountName $Username -UserPassword $password -UserPrincipalName ($Username+"@domain")-Office "Home Office US"`
Write-Host "User account object has been created"
The error is recieve is:
At H:\Scripts\Account Creation\Single User Account Creation.ps1:42 char:12
+ New-QADUser <<<< -Name $Displayname -ParentContainer $Path -FirstName $Firstname -LastName $Lastname -Description $Title -ObjectAttributes @{employeeID = $employeeid} -SamAccountName $Username
-UserPassword $password -UserPrincipalName ($Username+"@domain")-Office "Home Office US"`
+ CategoryInfo : NotSpecified: (:) [New-QADUser], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets.NewUserCmdlet
User account object has been created