Setting Primary Group for multiple users with Quest Powershell

Good day I need to Set the primary group of multiple user accounts to Domain Users is there a way to do this?
JT3865Asked:
Who is Participating?
 
Jamie McKillopIT ManagerCommented:
I would write that code like this:

$Users = Get-Content C:\Users\adjustin.BHBLAN\desktop\JustinPowerScripts\Test1.txt | ForEach-Object {
   Set-QADUser $_ -ObjectAttributes @{primarygroupid=513}
   Get-QADMemberof -identity $_ | select Name | export-csv -NoTypeInformation -path c:\Users\adjustin\Desktop\Test\$_-Groups.csv
   Start-Sleep -s 5
   Disable-QADUser $_
   Remove-QADMemberOf $_ -RemoveAll 
   Start-Sleep -s 5
   Move-QADObject -identity $_ -to bhb.bm/Marked_for_Deletion/Disabled_Users
 } 

Open in new window

0
 
Jamie McKillopIT ManagerCommented:
Hello,

The first thing you need to do is identify which users you want to set this on. This can either be through a query or a csv file. You would then pipe the results to this command:

Set-QADUser -ObjectAttributes @{primarygroupid=513}

-JJ
0
 
JT3865Author Commented:
Hey Jamie,

So i have a bunch of users in different OU's that have different Primary Groups set and we need them all to have the Domain Users Primary Group.  I also need to attach this command to a previous script i have as well.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
Jamie McKillopIT ManagerCommented:
If you want all your users to have this set just use this command:

Get-QADUser -SizeLimit 0 | Set-QADUser -ObjectAttributes @{primarygroupid=513}

That will sett all your users.

-JJ
0
 
JT3865Author Commented:
And I can specify this to the Script i have already written correct? So i can just pipeline it and add it to the existing script and it should work just fine?
0
 
Jamie McKillopIT ManagerCommented:
You should be able to but without seeing the script, I can't say for sure.

-JJ
0
 
JT3865Author Commented:
$Users = Get-Content C:\Users\adjustin.BHBLAN\desktop\JustinPowerScripts\Test1.txt | ForEach-Object {
   Get-QADUser  -SizeLimit 0 | Set-QADUser -ObjectAttributes @{primarygroupid=513} |
   Get-QADMemberof -identity $_ | select Name | export-csv -NoTypeInformation -path c:\Users\adjustin\Desktop\Test\$_-Groups.csv
   Start-Sleep -s 5
   Get-QADUser $_ | Disable-QADUser | Remove-QADMemberOf  -RemoveAll  
   Start-Sleep -s 5
   Move-QADObject -identity $_ -to bhb.bm/Marked_for_Deletion/Disabled_Users
 }
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.