troubleshooting Question

Change OU's and groups within AD using powershell and variables.

Avatar of Alex
AlexFlag for United Kingdom of Great Britain and Northern Ireland asked on
3 Comments1 Solution251 ViewsLast Modified:
Good morning all,

So I have a new issue, Shocker with it being a Monday Morning and all. I've been told that I need to change site codes for a number of OU's and change the associated groups which reside either in that OU or somewhere else.


I need to change only the site part of the group, i'm kind of debating deleting and recreating the groups however in the (Likely) event that I'll need to do this again I'm trying to make it self contained.

$OUs = Read-Host "Please enter the OU and Associated groups you'd like to change"

$NewOU = Read-Host "Please enter the new name of the OU and groups"

Foreach ($OU in $OUs){
Get-ADOrganizationalUnit -filter "Name -like $ou" | Set-ADOrganizationalUnit -DisplayName $NewOU }

Get-ADGroup -filter "Name -like $ou"

This is where I've got to and it's pretty shocking, maybe because I broke myself on Friday night and I've still got a headache.

Any hints on how I can do this would be great. I'm still trying to learn the intricacies of PowerShell so please advise rather than giving the straight answer :D

I don't think this is a hash group thing either.

Michael B. Smith
Managing Consultant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros