Тёмный

Powershell to add multiple users in multiple groups 

Abhijit Bole
Подписаться 352
Просмотров 47 тыс.
50% 1

First create the group.csv file as mentioned below
Username,groupname
User1,group1
User2,group2
User3,group3
#=========================================================================
import-csv "C:\temp\group.csv" | ForEach-Object {add-ADGroupMember -Identity $_.groupname -Members $_.username}
#=========================================================================

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 38   
@kdspland
@kdspland 5 лет назад
Great video this made my job a lot easier for adding nearly 200 users to several groups.
@Vicky.andtheMogs
@Vicky.andtheMogs 4 года назад
This has saved me so much work, I had 1300 different user/group combinations and it ran in like 5 seconds. Thanks so much for your video guide :)
@akhilreddy8658
@akhilreddy8658 8 месяцев назад
Did it work for different domains? I mean if the user is in different domains?
@neilokelly9208
@neilokelly9208 6 лет назад
Thanks bro :) Before this video, I almost had to add 350 people to a mulitple groups manually in A.d, you literally saved me hours of work.
@damongrambow7077
@damongrambow7077 7 лет назад
Thats what I was looking for and a lot simpler than I thought it would be! Thanks!!
@DivitUjjwal
@DivitUjjwal 3 года назад
Thanks a lot Sir. you saved 30 precious minutes of my life
@onslaught213
@onslaught213 2 года назад
This script saved me! The script I have is to add indiscualds to a group. Im writing a script to that will pull ownership of groups from users in a text file. A suggest for you if your looking to make another video
@jai3537
@jai3537 6 лет назад
Short and sweet. Thank you.
@msstrawberries02
@msstrawberries02 4 года назад
Simply and right to the point. Thank you
@gracenaghibi68
@gracenaghibi68 3 года назад
Thank you, this is Great, saved me lots of hours of tedious work
@halo2bullseye922
@halo2bullseye922 Год назад
Thanks for the video!
@Casshern_Sin
@Casshern_Sin 5 лет назад
Great video dude :)
@richievellalar3214
@richievellalar3214 3 года назад
I have a questions... can you answer me mate ? 1. Security group name : MicrosoftALL 2. Hostname : LAPTOP000012 I still add this security group manully using AD , Select computer in AD , apply the computer name : open the profile , under member , i can add the security group under computer. My questions to you i make easy apply via Powershell. What is command in order add security group under the hostname ( members ) can you help me.
@axelrumkorf9761
@axelrumkorf9761 4 года назад
Thanks for the video. I am a beginner in Powersehll and am currently trying to assign students to their classes at our school. Which modules need to be installed and/or imported to execute this script? And which service do I need to connect to? I would be very happy about an answer!
@Chris-ze3ic
@Chris-ze3ic 5 лет назад
Hi , I am currently trying to import multiple users to multiple different groups via powershell. The formatting of the CSV is: Group Name Members grp1   user 1 , user 2 , user 3 grp 2   user 5 , user 1 , user 4 grp 3    user 6 , user 5 , user 3 Some of the users that exist within the CSV do not currently exist so i have tried several different methods to import this but keep on getting errors import-csv "C:\Users\sys.c\Desktop\adgroups123.csv" | ForEach-Object {add-ADGroupMember -Identity $_.groupname -Members $_.username} is what im currently using, although i have tried other ways of trying to achieve this. I believe the issue that i am currently having is i need to do a -split(;) as the users are within the same cell , per row. I am therefore if i need to edit this or start over. I was wondering if anyone could help me with this as. I am unsure if i need to edit my csv to a different format or if powershell is capable of doing this within this format. ( i could not see anyone else trying this format on forums) Thanks!
@robshin8078
@robshin8078 6 лет назад
Thanks for the helpful video. What if you want to sync the AD groups to the CSV (which would mean adding and removing users)?
@borugahagayo3462
@borugahagayo3462 3 года назад
thanks very helpful.. you got a tutorial to add bulk users to AD?
@usmanshahid-vp3ie
@usmanshahid-vp3ie 3 месяца назад
Sorry Abhijit that is wrong (incorrect script), you added single to single group. you need nested loop to add multiple users in multiple groups
@أكلاتلذيذه-ز7ت
@أكلاتلذيذه-ز7ت 5 месяцев назад
hello sir... if you don't mind i need a command or a script to list of members of have access for shared folders.
@npanthri
@npanthri 5 лет назад
Let's say groups are in different different OU, You have not defined the location. How come it adding to the correct location ?
@TheMannersmanley
@TheMannersmanley 4 года назад
Great Video, is there a way to add more than one user to a group using a modified script/csv? I've been trying without success..
@anb8760
@anb8760 6 лет назад
What would be the best way to create a log for the changes made and the failures?
@jayant5555
@jayant5555 4 года назад
If you want to add multiple users from a DL or Security group to any Security Group or DL at once use this steps 1. Export the members in CSV file by their SamAccountName Get-ADGroupMember -identity “group name" | select SamAccountName | Export-csv -path -NoTypeInformation 2. Import the user using the SamAccountName in the new SG or DL import-csv "path of the CSV file" | ForEach-Object {add-ADGroupMember -Identity -Members $_.SamAccountName}
@vikramdongare8823
@vikramdongare8823 4 года назад
Thank you so much sir
@vikneshvaransaravanan3208
@vikneshvaransaravanan3208 4 года назад
Hi how to perform the addition of same users on same groups on different number of servers
@akhilreddy8658
@akhilreddy8658 8 месяцев назад
This script is not taking the email address. How can it take email
@sevencostanza3883
@sevencostanza3883 7 лет назад
Great video! I have two questions though, wouldn't this command add all users to groups 1,2 and 3? It seemed they only went into one group each. Secondly, what if I want to import data from two different locations, can you pipline two sets of data? e.g. '$a | $b | foreach-object {add-adgroupmember -identity $a -members $b}' I know this code is incorrect, I'm just wondering if it is possible to pipline in variables from multiple sources?
@abhijitbole5946
@abhijitbole5946 7 лет назад
Poopsmith Enterprises Hello, Thanks for your comments. For the first question. You can add any user in any group. You need to just edit the ".csv" file. In your scenario the csv file will be as mentioned below. User1,group1 User2,group1 User3,group1 User1,group2 User2,group2 User3,group2 User1,group3 User2,group3 User3,group3 ------------------------------------------------- Answer for the second question… Yes its is possible with the following code. $Users = Get-Content C:\temp\Users.txt $i = 0 ForEach($user in $users) { $group = (Get-Content C:\temp\groups.txt)[$i] add-ADGroupmember -Identity $group -Members $user $i++ }
@sevencostanza3883
@sevencostanza3883 7 лет назад
Excellent. Thank you so much! :D
@gobindsidhu5949
@gobindsidhu5949 7 лет назад
just love your name!
@CkmeLe0n
@CkmeLe0n 5 лет назад
Here is another way to add 1 user to multiple groups $User = Read-Host $Groups = @("group1","group2","groupN") ForEach ($Group in $Groups) {   Add-ADPrincipalGroupMembership $User -MemberOf $Group }
@martiscuola238
@martiscuola238 4 года назад
Hi, I'm trying to massively create a few hundreds Office 365 groups for ancemy organization, each with (possibly) multiple owners and members. could help me? how can I do? thank you in advance
@GetSetTravel94
@GetSetTravel94 2 года назад
It's helps alott
@dasoe55
@dasoe55 5 лет назад
Is there a way to make it not fail if the users are already made?
@MrJonathanRB
@MrJonathanRB 7 лет назад
thanks
@nikhilkalra1530
@nikhilkalra1530 4 года назад
Thanks.
@doualee8481
@doualee8481 3 года назад
how do i put this into a script?
Далее
НОВАЯ "БУХАНКА" 2024. ФИНАЛ
1:39:04
Просмотров 475 тыс.
КОГДА НАКРОШИЛ НА ПОЛ #shorts
00:19
V16 из БЕНЗОПИЛ - ПЕРВЫЙ ЗАПУСК
13:57
У КОТЕНКА ПРОБЛЕМА?#cat
00:18
Просмотров 984 тыс.
How to Create AD Users from CSV
22:41
Просмотров 28 тыс.
Beginner-friendly tutorial on PowerShell remoting
17:00
Intro to the CsvHelper Library for C#
27:12
Просмотров 27 тыс.
Learn to securely use Passwords with PowerShell
18:13
НОВАЯ "БУХАНКА" 2024. ФИНАЛ
1:39:04
Просмотров 475 тыс.