Swap the order of your exclusion code and the "ft" or "Format-Table". You're formatting your data down to where it doesn't have the DistinguishedName field and then trying to match against that missing field.
Search-ADAccount -accountinactive -datetime (get-date).AddMonths(-6) -usersonly | `
? {$_.DistinguishedName -notlike "*ou=Terminated Users,*" -and $_.DistinguishedName -notlike "*ou=vendors and others,*"} |`
ft Name,LastLogonDate |`
Out-File stale_users.txt