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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
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
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.