Hey everyone.. I'm fairly new to Powershell scripting and still working to understand a few of the basics--so sorry if this is a dumb question. I've found a few similar scripts out there that are somewhat related to what I'm doing, but none of them were quite able to get me in the right direction.
Here's the situation:
Users in our organization are organized in AD by department, and the OU structure is consistent, accurate and reflects the proper names for each department. Over the years as accounts were made, inconsistent department names have been entered in the "Office" field and the "Department" field of most users. What I'm hoping to do is write a script that will parse through a specified OU recursively and change the "Department" field and "Office" field of each user to reflect the name of its Parent OU.
Example:
company.local
OU: User OUs
- OU: Technical Support
- Fred, department = tech support
- Joe, department = Technical Sup.
- Susie, department = TechSupport
I'm hoping each person's department and office attribute can reflect the name of the OU it's in, so after the script runs, "Technical Support" is reflected on each user department/office.
So far this is the only progress I've made:
Get-ADUser $user | Set-ADObject -Replace @{"physicaldeliveryofficename"="Technical Support"}
Thank you