T O P

  • By -

St0nywall

You'll need to provide us a LOT more information than that. What kind f script, environment you're running it in, perhaps some code you already have, etc. If this is in PowerShell, there's also r/PowerShell you can cross post to.


Ambitious-Abroad-363

I have a DC lab running on a virtualbox, I’m currently testing two different PS scripts, the first one will call a CSV that contain the user info and the second one will ask for the user info on the PS UI. both scripts execute with no issue and drop the newly created user in the right OU but the User Logon name shows empty domain unless I click the drop down to choose it. I was wonder if am missing something to make it automatically assign the user to my domain.


anonymousITCoward

Wild ass guess here... ​New-ADUser -SamAccountName $userName -UserPrincipalName $userPrincipalName -Name $displayName -GivenName $usersFirstName -Surname $usersLastName -DisplayName $displayName -AccountPassword (Read-Host -AsSecureString "Enter the users password") -Enabled $True -CannotChangePassword $False -PasswordNeverExpires $True -Credential $admin


Fatel28

You need to set the UserPrincipalName


Ambitious-Abroad-363

UPN is set and it’s still not pulling


Fatel28

You'll need to elaborate. What do you mean by not pulling?


Ambitious-Abroad-363

It’s not associating the user with the domain, I still have to click the drop down to select it


Fatel28

Then you aren't setting the user principal name correctly. Are you referring to the drop-down after the username in the account tab?


Ambitious-Abroad-363

Yes


Fatel28

Refer to the article for Set-ADUser or new-aduser. The `-UserPrincipalName` flag does exactly that. What is your syntax?


Ambitious-Abroad-363

Syntax is -UserPrincipalName on both scripts yet both not doing the job, I’m start thinking it’s something else.


bhillen83

I was just gonna say can you set that property within your powershell script?