Thanks Dave you are amazing
Perfect!
I think I will take a break now
Below creates the new groups that are required and then modifies the gidNumber.
$Groups = Import-Csv C:\Scripts\CSVFILE.csv -UseCulture
foreach ($Group in $Groups) {
New-ADGroup -Name $Group.Name -Description $Group.Description -GroupCategory "Security" -GroupScope "Universal" -DisplayName $Group.displayNamePrintable -Path $Group.Path -SamAccountName $Group.SamAccountName -Verbose
}
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
}
}
Once again many thanks.
Iain