Search code examples
powershellpowershell-2.0powershell-3.0

How can I change the Managed By to a single user in multiple groups using a csv


How can I change the "Managed By" name in a Security Group in AD to a single user in multiple groups using a csv in powershell?


Solution

  • I would suggest something like this:

    $manager = Get-ADUser -Identity "USERNAME"
    
    Import-Csv groups.csv | ForEach-Object {
        Set-ADGroup -Identity $_.Group -ManagedBy ($manager.DistinguishedName)
    }
    

    You can even skip the Get-ADUser part and just do:

    Import-Csv groups.csv | ForEach-Object {
        Set-ADGroup -Identity $_.Group -ManagedBy "USERNAME"
    }