Avatar of lianne143
lianne143
Flag for United States of America asked on

How to import users from notepad to a security group.

Hi

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.
PowershellActive Directory

Avatar of undefined
Last Comment
lianne143

8/22/2022 - Mon
serialband

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

ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
lianne143

ASKER
Hi

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:
'DC=domain,DC=local'.
At line:1 char:1
+ Add-ADGroupMember -Identity "AllMkt" -Members $members
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: ({56F21980-6F13-...1-99D8E8930101}:ADPrincipal) [Add-ADGroupMember], ADI
   dentityNotFoundException
    + FullyQualifiedErrorId : SetADGroupMember.ValidateMembersParameter,Microsoft.ActiveDirectory.Management.Commands.
   AddADGroupMember

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.
lianne143

ASKER
Do i need to try with distinguishedNames, SIDs, or samAccountNames ?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
footech

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 ("-").
lianne143

ASKER
Great footech

That worked  :)

Points awarded and many thanks :)