@matte ! You are ingenius :). The following version of the command works! Thank you very very much for the help! That gave me just what I needed.
Foreach ($hostname in ((Get-SmHost).Hostname)) { (get-smresources -HostName $hostname -PluginCode SCSQL -UseKnownResources) | Select-Object -Property dbname,dbid >> databases.txt}