Quantcast
Viewing all articles
Browse latest Browse all 21975

Powershell : List Users with same primary group

Hello everybody

After reading a lot I finally decided to post :)

First : I am not a PS expert, just have some basis allowing me to do what I need (until today :P)

I am looking for a way (in powershell) to make a list of users having the same primary group.

For example :I have group1 and group2

I would like to have a list of users having group1 as primary, and a list of user having group2 as primary and so on...

The reason is :We are migrating from a linux based environment to an MS active directory environment. Users and groups are already migrated to the AD.

As you may know, in Linux it's possible to map a network drive depending of which primary group you belong to. In order to recreate the same thing on the user view, I am making an Organization Unit per group and set  GPOs connecting the correct network drive for each of them.

As we have more than 1000 users, I dont want to move my users one per one in the right OU. That's why I was wondering if there is a way to do something in this style :

Get-ADGroupMember -identity TESTGROUP | Move-ADObject -TargetPath 'OU=Internal Users,OU=Users,OU=TEST,DC=CONTOSO,DC=ORG'

This command moves all member of "TESTGROUP" to an Organization Unit named "Internal Users".

What I am exactly looking for is a command Moving all Users having "TESTGROUP" as primary group to an Organization Unit.

If anybody as an idea, it would be highly appreciated :)

Wish you all a nice day.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>