Hi All I was hoping you might be able to guide me with my query below.
I have a requirement to create multiple Active directory Groups (and users but not in this script) where the gidNumber has to be modified (for Linux Groups).
I can successfully obtain the GID from the AD Group SID, but I am then unable to pass this to the Set-ADGroup -replace parameter.
Headers (for CSV file):
Name,SamAccountName,Path,DisplayName,Description
Test Group,Test Group,”OU=Groups,DC=HomeDomain,DC=Local”,tstgrp,Test Group
Test2 Group,Test2 Group,”OU=Groups,DC=HomeDomain,DC=Local”,tstgrp2,Test Group
$GID = foreach ($group in $groups){
Get-adgroup $group.SamAccountName | select @{l="GID";e={[int]$_.SID.Value.Substring([int]$_.SID.Value.Lastindexof("-")+1)+1000}} | Select -ExpandProperty GID
Get-adgroup $group.SamAccountName | Set-ADGroup -Replace @{gidNumber="GID"} -Verbose
}
I think it is to do with the @{gidNumber="GID"}
scriptblock but cannot think how to take each GID and then put it into the gidNumber one at a time.
This is the error I get :
Set-ADGroup : The parameter is incorrect
At line:8 char:37
+ Get-adgroup $group.SamAccountName | Set-ADGroup -Replace @{gidNumber="GID"} -Ver ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (CN=Test Group,DC=Homenet,DC=Local:ADGroup) [Set-ADGroup], ADInvalidOperationException
+ FullyQualifiedErrorId : ActiveDirectoryServer:87,Microsoft.ActiveDirectory.Management.Commands.SetADGroup
Any assistance would be very much appreciated.