IT Guy
asked on
Correct syntax for CSV spreadsheet to create Server 2016 AD accounts
I currently have a spreadsheet that contains all employee first names, last names, & logon user names (see below).
I need to know exactly which rows and columns this information needs to be put within an Excel CSV spreadsheet and where other information such as the user's AD passwords & any other information needs to be put so that these user accounts can be created within Server 2016 Active Directory.
I also need to know the exact command line or power shell command needs to be used that will create these user accounts within Active Directory.
Please provide me with guides or URL resources that explain how this can be done. I have attached an example spreadsheet that contains the user first names, last names, and AD user names for the accounts that need to be created.
ADusers.csv
I need to know exactly which rows and columns this information needs to be put within an Excel CSV spreadsheet and where other information such as the user's AD passwords & any other information needs to be put so that these user accounts can be created within Server 2016 Active Directory.
I also need to know the exact command line or power shell command needs to be used that will create these user accounts within Active Directory.
Please provide me with guides or URL resources that explain how this can be done. I have attached an example spreadsheet that contains the user first names, last names, and AD user names for the accounts that need to be created.
ADusers.csv
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
When I run the following command within PowerShell (running as an administrator) .\un.ps1 I get the error message “ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null.
At C:\Support\UN\UN.ps1:12 char:232
+ ... scription" -AccountPassword (ConvertTo-SecureString $Password -AsPlai ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,Microsoft .PowerShel l.Commands .ConvertTo SecureStri ngCommand
ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null.
At C:\Support\UN\UN.ps1:12 char:232
+ ... scription" -AccountPassword (ConvertTo-SecureString $Password -AsPlai ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidation Exception
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,Microsoft .PowerShel l.Commands .ConvertTo SecureStri ngCommand” which displays for every username that I attempt to create (see the screenshot).
I have included the CSV spreadsheet I am using with this command.
What needs to be done to fix this so I will be able to successfully import the information to create these usernames within Server 2016 Active Directory?
Please let me know if any further information is needed.
In this case the CSV file is saved in the "File format is CSV UTF-8 Comma delimited" format. Is this the correct format to save the file in?
UN.csv
File-format-is-CSV-UTF-8-Comma-delim.PNG
At C:\Support\UN\UN.ps1:12 char:232
+ ... scription" -AccountPassword (ConvertTo-SecureString $Password -AsPlai ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
ConvertTo-SecureString : Cannot bind argument to parameter 'String' because it is null.
At C:\Support\UN\UN.ps1:12 char:232
+ ... scription" -AccountPassword (ConvertTo-SecureString $Password -AsPlai ...
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [ConvertTo-SecureString], ParameterBindingValidation
+ FullyQualifiedErrorId : ParameterArgumentValidatio
I have included the CSV spreadsheet I am using with this command.
What needs to be done to fix this so I will be able to successfully import the information to create these usernames within Server 2016 Active Directory?
Please let me know if any further information is needed.
In this case the CSV file is saved in the "File format is CSV UTF-8 Comma delimited" format. Is this the correct format to save the file in?
UN.csv
File-format-is-CSV-UTF-8-Comma-delim.PNG
ASKER
And here is the context of the UN.ps1 PowerShell command:
$Users = Import-Csv -Path "C:\support\un\UN.csv"
foreach ($User in $Users)
{
$Displayname = $User.Firstname + " " + $User.Lastname
$UserFirstname = $User.Firstname
$UserLastname = $User.Lastname
$OU = "$User.OU"
$SAM = $User.SAM
$UPN = $User.Firstname + "." + $User.Lastname + "@" + $User.Maildomain
$Description = $User.Description
$Password = $User.Password
New-ADUser -Name "$Displayname" -DisplayName "$Displayname" -SamAccountName $SAM -UserPrincipalName $UPN -GivenName "$UserFirstname" -Surname "$UserLastname" -Description "$Description" -AccountPassword (ConvertTo-SecureString $Password -AsPlainText -Force) -Enabled $true -Path "$OU" -ChangePasswordAtLogon $false –PasswordNeverExpires $true -server domain.loc
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Firstname | Lastname | Maildomain | SAM | OU | Password | Description
User | Test01 | contoso.com | utest01 | OU=Standard Users,OU=Users,DC=domain,D
I understand all of the columns except for the SAM column
What does SAM refer to? What would I put down for this column in the Excel CSV spreadsheet?