I fixed it. Had to change the following line:
$Dummyvar = $Dummyvar + GroupObj.Name
to
$Dummyvar = $Dummyvar + $GroupObj.Name

Still I would like to be able to scify the domain with the group name not just the name of the group.