I am new to PowerShell and AD, I have a small task which I am finding difficult to complete. Can someone please help me here ?
The task is as follows:
There are 3 ADgroups defined in AD, namely
"CN=Technology Champion,OU=Exchange Distribution Lists,OU=Groups,DC=dpsnc,DC=local"
"CN=Media Contacts-ES,OU=School Groups,OU=Groups,DC=dpsnc,DC=local"
"CN=Media Contacts-SS,OU=School Groups,OU=Groups,DC=dpsnc,DC=local"
What I need to do is among all the ADUsers that exist in 'Domain Users' , I need to check whether a ADUser belongs to any one of the above mentioned groups. If the ADUser belongs to atleast any one of the above mentioned group then check his 'Department Id' attribute (which would be department_id = "304-BEE") and based on the department id attribute I have to move the ADObject to appropriate ADgroup whose name contain the 'department_id'
"CN=vBrick-ContentApprover.304-BEE.VC - Elementary,OU=Groups,OU=304-BEE,OU=VC - Elementary,DC=dpsnc,DC=local"
"CN=vBrick-ContentApprover.306-BMS.VC - Middle,OU=Groups,OU=306-BMS,OU=VC - Middle,DC=dpsnc,DC=local"
"CN=vBrick-ContentApprover.308-BUR.VC - Elementary,OU=Groups,OU=308-BUR,OU=VC - Elementary,DC=dpsnc,DC=local"
For example:
If a ADUser belongs to ADgroup "CN=Media Contacts-ES,OU=School Groups,OU=Groups,DC=dpsnc,DC=local" then I need to check his dept_id attribute, suppose the dept_id value is "304-BEE", then I need to move that ADObject to ADgroup "CN=vBrick-ContentApprover.304-BEE.VC - Elementary,OU=Groups,OU=304-BEE,OU=VC - Elementary,DC=dpsnc,DC=local"
NOTE: The Powershell script should be compatible with Windows Server 2003 R2 and Windows Server 2012
Nikhil Katre