jaols / ADExportImport

3 stars 1 forks source link

Import-AdUsers.ps1 returns "The name provided is not a properly formed account name" #2

Closed FrankTheCat09 closed 1 year ago

FrankTheCat09 commented 1 year ago

Import-AdUsers.ps1 returns "The name provided is not a properly formed account name"

ImportAdUsers error
FrankTheCat09 commented 1 year ago

Issue seems to be related to either sam names from export being over 20 characters and -name field containing commas for LastName, FirstName. Here is an article - https://devblogs.microsoft.com/scripting/how-can-i-work-with-a-cn-that-has-a-comma-in-it/

jaols commented 1 year ago

Thank you for discovering this, and the suggestion!

The issue was indeed with the New-Aduser command, but it did not help to escape the comma in the name. I had to add the samAccountName option.

https://social.technet.microsoft.com/Forums/en-US/900a3157-7b47-43c9-b5f9-fee39c51539f/not-able-use-comma-in-name-attribute-while-creating-new-user-in-ad-using-powershell?forum=ITCG

A new version of I mport-AdUsers.ps1 are available.