I see a few problems, first your query has some extra double quotes and should be this:
$DBLogSQL = "select name from sys.master_files where database_id = DB_ID(N'$dbname') and physical_name not like '%ldf'"
Second the important thing to remember with PowerShell everything is an object, so you'll need to reference the column name as properties. Here's one way to do it, if you're only expecting a single record in PowerShell V2:
$DBDataFileName = get-sqldata -sqlserver "$primary" -dbname pubs -qry $DBLogSQL | select -ExpandProperty name
Third declare a variable $DBLogSQL, but then use a variable $DBDataSQL