Justin Tucker
asked on
Powershell issue with Bulk adding users from csv.
Good Day,
Looking to get a bulk csv list of SamAccountName's added to a AD group was wondering if any one had any suggestions.
Currently using this script:
Import-Module ActiveDirectory
$Users = Get-Content "C:\Users\******\Desktop\*******" | ForEach-Object {Add-ADGroupMember -Identity "GroupName" -Members $_.'User-Name'}
Getting error message "Add-ADGroupMember: Cannot validate argument on parameter 'Members'. The argument is Null or empty.
Can anyone assist with this?
ASKER
Hey Jose,
Thanks for your help, it didn't work I adjusted the csv file to state 'User-Name' like you suggested however, I'm still running into the Cannot Validate argument on parameter 'Members' message. Any thoughts?
Thanks for your help, it didn't work I adjusted the csv file to state 'User-Name' like you suggested however, I'm still running into the Cannot Validate argument on parameter 'Members' message. Any thoughts?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
HI Jose!
Thanks that worked perfectly! Thanks for your help!
Thanks that worked perfectly! Thanks for your help!
I'm glad to help Justin!
If you're using a CSV, then you don't need to use Get-Content you use Import-CSV instead, and you're trying to save that execution into a var that doesn't provide anything :)
this would be my correction:
single liner:
Open in new window
CSV for this one must contain the field: "user-name" like this:Open in new window
Multiple LinesOpen in new window
This multiline version also uses the same CSV. no other changes are required.
Multiline in case the users already exist but you do want to continue :)
Multiple Lines
Open in new window