How to Rename AD Group in PowerShell
This tutorial demonstrates how to rename an active directory group in PowerShell.
PowerShell Rename AD Group
Modifying the properties of the AD group is an easy operation using the PowerShell commands. We can use the Set-ADGroup
command to modify the properties of an AD group which also includes renaming the group.
First, ensure the ActiveDirectory
module is installed and imported into your environment. Follow the steps below to install the ActiveDirectory
in your system.
-
Go to the Start menu and open the PC
Settings
. -
When the settings are open, go to
Apps
. -
Click on
Optional Features
on theApps
page. -
Click
Add Feature
on the opened page and look forRSAT: Active Directory Domain Services and Lightweight Directory Services Tools
. -
Select the
RSAT: Active Directory Domain Services and Lightweight Directory
and install it.
Once the active directory is installed, we should run the following command to import the ActiveDirectory
module.
Import-Module ActiveDirectory
Now to rename the ActiveDirectory
group, we can use the get-adgroup
, set-adgroup
, and rename-adobject
commands. Run the following command to rename the ADGroup
:
get-adgroup -Identity 'OldGroupName' | % { set-adgroup -samaccountname 'NewGroupName'; $_ | rename-adobject -newname 'NewGroupName' }
The above command will successfully rename the ADGroup
. Where the OldGroupName
is the existing group name, and NewGroupName
is the name to be changed, the get-adgroup
command is used to identify the group, and the set-adgroup
with samaccountname
is used to rename the group.
One more important thing to mention here is that to run this command successfully, you need to have a default server for ActiveDirectory
, which will run the active directory web services. If you don’t have a server installed, the web services will not work, and the above command will throw an error.
Sheeraz is a Doctorate fellow in Computer Science at Northwestern Polytechnical University, Xian, China. He has 7 years of Software Development experience in AI, Web, Database, and Desktop technologies. He writes tutorials in Java, PHP, Python, GoLang, R, etc., to help beginners learn the field of Computer Science.
LinkedIn Facebook