As Lee_Dailey commented it is a waste to ask for all properties when you only want a few..
Also, you should always test if the user entered in the Read-Host can be found at all, because anyone can type just about anything there.
Try
$Username = Read-Host "Enter User ID"
# try and find the user in AD
$user = Get-ADUser -Filter "SamAccountName -eq '$Username'" -ErrorAction SilentlyContinue
if ($user) {
# Get-ADGroup already returns these properties by default:
# DistinguishedName, GroupCategory, GroupScope, Name, ObjectClass, ObjectGUID, SamAccountName, SID
# so only ask for the extra properties you need
$user | Get-ADPrincipalGroupMembership | Get-ADGroup -Properties Description, ManagedBy | ForEach-Object {
# try and get the group manager from the DistinguishedName in the ManagedBy property
$manager = if ($_.managedBy) { (Get-ADUser -Identity $_.managedBy).Name } else { 'Not set' }
[PsCustomObject]@{
Name = $_.Name
Description = $_.Description
ManagedBy = $manager
}
} | Export-Csv -Path (Join-Path -Path 'C:\Temp' -ChildPath ('{0:yyyy-MM-dd}-{1}.csv' -f (Get-Date), $user.Name )) -NoTypeInformation
}
else {
Write-Warning "User '$Username' not found.."
}