Search code examples
powershellps

List and rename ADgroup in powershell


am actually new on PS so I need to get some help running some commands.

Working on Active Directory, I need to get the name of a group and change its name, could be something like this.

Get-ADGroup -Identity 'test' | set-adgroup -Identity 'test1'

I already tried -SAMACCOUNTNAME as well.

Can I get some help please?

Thanks in advance


Solution

  • Get-ADGroup -Identity 'test' | Rename-ADObject -NewName 'test1'
    

    have a look here

    "The Rename-ADObject cmdlet renames an Active Directory object. This cmdlet sets the Name property of an Active Directory object that has a Lightweight Directory Access Protocol (LDAP) display name (ldapDisplayName) of name. To modify the given name, surname, and other name of a user, use the Set-ADUser cmdlet. To modify the Security Account Manager (SAM) account name of a user, computer, or group, use the Set-ADUser, Set-ADComputer, or Set-ADGroup cmdlet."

    ps. for Get-ADGroup you need '-Identity' to be one of

    • A distinguished name
    • A GUID (objectGUID)
    • A security identifier (objectSid)
    • A security accounts manager account name (sAMAccountName)