Hello John,
For this purpose, you need to modify the CreateGroup function used in your script. Find below the function modified per requirements. We've added the following lines:
# Add Owner to group
$group.Add("Adaxes://$ownerDN")
Complete function:
# Function to create groups
function CreateGroup($ouDN, $name, $description, $displayName, $sAMAccountName, $groupType, $ownerDN)
{
$ou = $Context.BindToObjectByDN($ouDN)
$group = $ou.Create("group", "CN=$name")
$group.Put("description", $description)
$group.Put("displayName", $displayName)
$group.Put("sAMAccountName", $sAMAccountName)
$group.Put("groupType", [int]$groupType)
$group.Put("managedBy", $ownerDN)
$group.SetInfo()
# Add Owner to group
$group.Add("Adaxes://$ownerDN")
$groupSid = $group.Get("objectSid")
return ,$groupSid
}