Link to home
Start Free TrialLog in
Avatar of lianne143
lianne143Flag for United States of America

asked on

How to import users from notepad to a security group.


I have a notepad called "AllUser" containing 1000 users. I have created a Universal security group in the active directory called "AllMkt" and would like to import all the 1000 users into this universal security group.

Is there any Powershell command  and let me know the best way of doing this.

If it is Powershell please post me the exact syntax that i need to run.

Any tutorials and help much appreciated.
Avatar of serialband
Flag of Ukraine image

You could just open powershell and cut and paste the members after you place commas between each user name.
 Add-ADGroupMember -Identity MySecurityGroup -Members Member01,Member02

Open in new window

Avatar of footech
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lianne143



Exported only the GUIDs of all the 1000 users to a notepad and ran the above command and it gives an error.

Windows PowerShell
Copyright (C) 2014 Microsoft Corporation. All rights reserved.

PS H:\> $members = Get-Content "c:\temp\AllUser.txt"
PS H:\> Add-ADGroupMember -Identity "AllMkt" -Members $members
Add-ADGroupMember : Cannot find an object with identity: '{56F21980-6F13-431+A2:A1188D-A611-99D8E8930101}' under:
At line:1 char:1
+ Add-ADGroupMember -Identity "AllMkt" -Members $members
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ({56F21980-6F13-...1-99D8E8930101}:ADPrincipal) [Add-ADGroupMember], ADI
    + FullyQualifiedErrorId : SetADGroupMember.ValidateMembersParameter,Microsoft.ActiveDirectory.Management.Commands.

PS H:\>

I searched the corresponding username of the GUID and the user exist on our AD.

Please let me know if i am missing any thing.
Do i need to try with distinguishedNames, SIDs, or samAccountNames ?
When using GUIDs, they shouldn't have the braces at either end.  Also, I see in the GUID for your error sample a "+" and a ":", there should be only letters, numbers, and hyphens ("-").
Great footech

That worked  :)

Points awarded and many thanks :)