I want to create many AD users from a CSV file.
The CSV file has the following columns:
In the CSV are passwords defined.
After spending hours in testing various combinations of these CMDlets I've got this one working, but only with one entity.
$csv = Import-Csv -Delimiter ";" -Path "C:\import.csv"
$csv | New-ADUser -Enabled $true -ChangePasswordAtLogon $true -AccountPassword (ConvertTo-SecureString $csv.AccountPassword -AsPlainText -Force)
When I add a second entity, I get this error:
ConvertTo-SecureString : The argument can not be bound to the parameter "string" because it is NULL.
When I delete the column "AccountPassword" it's also working with multiple entities.
So the problem is just the function with SecureString.
I've already found this:
This methode with foreach is working, but I really don't like it because of so much variables...
I just can't believe there is no method which is working with setting passwords on multiple entities!