Hi Team,<\/p>\n
How to create multiple groups in Active directory.<\/p>\n
Regards,<\/p>\n
Chnadu<\/p>","upvoteCount":5,"answerCount":4,"datePublished":"2019-07-19T06:50:46.000Z","author":{"@type":"Person","name":"spiceuser-fchmo","url":"https://community.spiceworks.com/u/spiceuser-fchmo"},"suggestedAnswer":[{"@type":"Answer","text":"
Hi Team,<\/p>\n
How to create multiple groups in Active directory.<\/p>\n
Regards,<\/p>\n
Chnadu<\/p>","upvoteCount":5,"datePublished":"2019-07-19T06:50:46.000Z","url":"https://community.spiceworks.com/t/powershell-to-create-multiple-groups-in-ad/721647/1","author":{"@type":"Person","name":"spiceuser-fchmo","url":"https://community.spiceworks.com/u/spiceuser-fchmo"}},{"@type":"Answer","text":"
Hello,<\/p>\n
Simply, use the following script in Powershell in order to achieve your goal.<\/p>\n
\t# make sure you have RSAT Tool Installed\n \t# Make Sure you imported Active Directory Module before running this command\n \n # Global Variables\n \t# OU Path of the Group in which we want to create groups\n \t\t$path = \"OU=testing,DC=analysys,DC=com\" \n\t\t\n \t# Domain Admin Credentails\n\t\t$cre = get-Credential\n\t\t\n\t#Main Server\n \t\t$srvr = \"Dc-man\"\n \n # username is domain users \"SAM Account \" name , use Get-AdUser to find our SAM name of the user.\n \t\t$usr = \"Will.Smith\",\"ricky.Martin\",\"kate.Winslet\",\"Michael.jackson\"\n\t\t\n #Dfine Group which need to be created\n \t\t$grpname = \"Music\",\"Movies\",\"Famous_Singers\",\"HollyWood\"\n\n # Lets use ForEach patters to create the group\n \n \tforeach ($group in $grpname) {\n \t\t$name = $group\n\t\t\n\t\t\t# Just a console message\n\t\t\twrite-Host -ForegroundColor Magenta \"Grouname is $name.\"\n\t\t\t\n\t\t\t# Using AD Module\n\t\t\tNew-ADGroup -Path $path -Name $name -GroupCategory Security -GroupScope Global -Server $srvr -Credential $cre \n\t\t\t\n\t\t\t# Just a console message\n\t\t\tWrite-Host -ForegroundColor Yellow \"Group $name Created, let me add users in to this group.\" \n\t\t\t\n\t\t\t# Using AD Module\n\t\t\tAdd-ADGroupMember $name $usr -Server $srvr\n\t\t\t\n\t\t\t# Just a console message\n\t\t\tWrite-Host -ForegroundColor Green \"Member are added to the group $name .\"\n\n####Everything Should be done by now ###\n\n }\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-07-19T06:54:48.000Z","url":"https://community.spiceworks.com/t/powershell-to-create-multiple-groups-in-ad/721647/2","author":{"@type":"Person","name":"hsadeghpour","url":"https://community.spiceworks.com/u/hsadeghpour"}},{"@type":"Answer","text":"