Link to home
Start Free TrialLog in
Avatar of Mr Woober
Mr WooberFlag for Norway

asked on

Populate department based on OU - Powershell

Hi,

Have some trouble getting this one :)

Scenario : Large organization with several offices/departments around the country. All offices have their own OU.
Department defines the different offices.

ex. get-aduser -searchscope "OU=office1,DC=Company,DC=intern" -filter * -properties department,company | set-aduser -department Office1.

get-aduser -searchscope "OU=$OU1,DC=Company,DC=intern" -filter * -properties department,company | set-aduser -department $OU1

$OU1 should be generated from the object name that is defined on the user.

ex. company.inten/Office1/mr-woober

So again, what i would like is to populate $OU1 to be the Office1 as given in example over. Powershell should populate this value.

The reason is that there are close to 70 offices and these changes alot :) Want to automate most of the populating.....
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mr Woober

ASKER

Perfect solution. Modified to my environment and worked like a charm