SlideShare a Scribd company logo
1 of 1
#PowerShell Script to add multiple users to a group in AD
Import-Module ActiveDirectory
#Import users and groups details from a CSV file
$List = Import-Csv "C:Usershidden_nameDocumentsAdd-ADGroupMember*.csv"
#Loop through all users in the CSV
ForEach ($Item In $List) {
#Add users to the specified groups
Add-ADGroupMember -Identity $Item.GroupName -Member (Get-ADUser
$Item.AccountName)
Write-Output "User $($Item.AccountName) added to $($Item.GroupName) SecurityGroup!" |
Out-File 'C:hidden_nameJosephaddADgroupmember.txt' -Append
}

More Related Content

What's hot

Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Yusuke Wada
 
RSS Application Using Dom
RSS Application Using Dom  RSS Application Using Dom
RSS Application Using Dom abdullah roomi
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYusuke Wada
 
An Introduction to WordPress Hooks
An Introduction to WordPress HooksAn Introduction to WordPress Hooks
An Introduction to WordPress HooksAndrew Marks
 
Ako prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s ElasticsearchAko prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s Elasticsearchbart-sk
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBMongoDB
 
Dadabik install
Dadabik installDadabik install
Dadabik installinnutum
 
Tools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionTools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionJesus Manuel Olivas
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performanceYehuda Katz
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Naresha K
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and ModernizrJussi Pohjolainen
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBMongoDB
 

What's hot (17)

Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5Twib in Yokoahma.pm 2010/3/5
Twib in Yokoahma.pm 2010/3/5
 
RSS Application Using Dom
RSS Application Using Dom  RSS Application Using Dom
RSS Application Using Dom
 
YAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
 
An Introduction to WordPress Hooks
An Introduction to WordPress HooksAn Introduction to WordPress Hooks
An Introduction to WordPress Hooks
 
Ako prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s ElasticsearchAko prepojiť aplikáciu s Elasticsearch
Ako prepojiť aplikáciu s Elasticsearch
 
Blog Hacks 2011
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
 
Dev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDBDev Jumpstart: Build Your First App with MongoDB
Dev Jumpstart: Build Your First App with MongoDB
 
Dadabik install
Dadabik installDadabik install
Dadabik install
 
Tools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 EditionTools and Projects Dec 2018 Edition
Tools and Projects Dec 2018 Edition
 
Sprout core and performance
Sprout core and performanceSprout core and performance
Sprout core and performance
 
Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014Better Selenium Tests with Geb - Selenium Conf 2014
Better Selenium Tests with Geb - Selenium Conf 2014
 
Php 2
Php 2Php 2
Php 2
 
JQuery
JQueryJQuery
JQuery
 
A Look at ASP.NET MVC 4
A Look at ASP.NET MVC 4A Look at ASP.NET MVC 4
A Look at ASP.NET MVC 4
 
Short intro to JQuery and Modernizr
Short intro to JQuery and ModernizrShort intro to JQuery and Modernizr
Short intro to JQuery and Modernizr
 
Webinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDBWebinar: Getting Started with Ruby and MongoDB
Webinar: Getting Started with Ruby and MongoDB
 
Webdriver
WebdriverWebdriver
Webdriver
 

PowerShell Script to add multiple users to a group in AD

  • 1. #PowerShell Script to add multiple users to a group in AD Import-Module ActiveDirectory #Import users and groups details from a CSV file $List = Import-Csv "C:Usershidden_nameDocumentsAdd-ADGroupMember*.csv" #Loop through all users in the CSV ForEach ($Item In $List) { #Add users to the specified groups Add-ADGroupMember -Identity $Item.GroupName -Member (Get-ADUser $Item.AccountName) Write-Output "User $($Item.AccountName) added to $($Item.GroupName) SecurityGroup!" | Out-File 'C:hidden_nameJosephaddADgroupmember.txt' -Append }