Possibilities are that you have an empty line in the input file. Or leading or trailing space(s) in one or more lines in the input file. Or, if I take your input file contents literally, there are quotation marks at the beginning and end of each line!
See if this works any better:
Get-Content "C:\Scripts\AD\UserSecGroupExport\OUList.txt" |
ForEach-Object{
$Site = $_.Trim()
$Site = $Site.Trim('"')
if ($Site.Length -gt 13){ # long enough to hold DC's and at least one OU?
Get-ADUser -Filter -Properties surname, givenname, samaccountname, mail, manager, office, physicaldeliveryofficename, enabled, memberof -searchbase $Site |
ForEach-Object {
$User = $_
$User.memberof |
ForEach-Object {
$g = Get-ADGroup -Identity $_ -Properties *
[PSCustomObject]@{
Surname = $User.surname
FirstName = $User.givenname
SamAccountName = $User.samaccountname
EmailAddress = $User.mail
LineManager = $user.manager
Office = $user.office
PhysicalOffice = $user.physicaldeliveryofficename
Enabled = $User.enabled
GroupName = $g.Name
GroupDescription = $g.Description
GroupCategory = $g.GroupCategory
GroupMail = $g.mail
}
}
}
}
} | Export-Csv -Path "C:\Scripts\AD\UserSecGroupExport\GroupMembershipExport-$(Get-Date -format dd_MM_yyyy).csv" -NoTypeInformation -Encoding UTF8