Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Set AD group gidNumber for multiple groups

$
0
0

OK, the code should just need a small update to include a single call to Get-ADGroup, then. Try this:

foreach ($csvEntry in $groups)
{
    try
    {
        $group = Get-ADGroup -Identity $csvEntry.SamAccountName -ErrorAction Stop

        $GID = [int]$group.SID.Value.Substring([int]$group.SID.Value.Lastindexof("-")+1)+1000
    
        $group | Set-ADGroup -Replace @{gidNumber=$GID} -Verbose -ErrorAction Stop
    }
    catch
    {
        # handle error however you like
    }
}


Viewing all articles
Browse latest Browse all 13067

Trending Articles