1- Import-Module activedirectory
2- $users =Import-Csv 'C:\Testuser.csv'
3- Foreach ($user in $users) {
4- $filter = "name -like '$($user.name)'"
5- $pwd = ConvertTo-SecureString "$($user.pwd)" -AsPlainText -Force } $users |
6- New-ADUser -Country IN -ChangePasswordAtLogon $true -Path "ou=testou,dc=test,dc=local" -AccountPassword (ConvertTo-SecureString "$pwd" -AsPlainText -Force) -passthru |
7- Enable-ADAccount
CSV File : name,givenname,lastname,displayname,samAccountname,department,description,city,pwd)
This is a script for creating users from CSV file.
The script works perfectly but what i to know is the meaning of this ($user in $users).
Why do we have to use it, why can't we use $users.name instead of $user.name
With Regards,
Vincent