We have a security group which has user’s from multiple OU’s, now i’m trying to get it sorted out and move/copy those users to their appropriate group’s. So my questions is, how i can filter out user’s from a group using OU as a filtering parameter?
I know i can get user list using, but that’s pretty much all what i understand from powershell scripting
You might make a step back and take a little time to start to learn the very basics of Powershell. … most of the time it is better to learn to walk before you start to run.
If you like to filter on the OU of a user you can use either the canonical name or the distinguished name of the user. Compaired to the file system would that be a kind of the path of a file.
Yeah i know that, but my work enviroment is kinda hectic and so little time to actually study these things. So my method is to learn on the fly when i’m trying to accomplish something
Most people seem to use -searchbase with another command, then use the output with get-adgroupmember, or vice versa. OU’s can’t be used in filters for some reason.
You can add accounts to groups with the cmdlet Add-ADGroupMember or Add-PrincipalADGroupMembership. But I’d recommend to use the sAMAccountName instead of the name of the accounts - that’s more specific and less error prone when there are accounts with the same name - lastname combination.
Please read the complete help including the examples to learn how to use these cmdlets.