I'm trying to take a list of groups and use the name of the group to create a Group Policy Object with the same name, but I want to replace the Group portion of the name with GPO, however, it comes out as one long string, and creates the name of the GPO as one long name.
$groupname = Get-ADGroup -searchbase "OU=examplegroup,DC=example,DC=com" -Filter * | where { $_.name -ne "example"} | select -ExpandProperty name
$groupname = $groupname.replace("Group","Gpo")
foreach ($group in $groupname) { New-GPO -name "$groupname"}