you have to qualify the database in the query with a ?. you can also load the result into a table to make them searchable
CREATE TABLE #tmp(dbname VARCHAR(256),username VARCHAR(256))
INSERT #tmp EXEC sp_MSforeachdb 'select ''?'',name
from [?].sys.database_principals
where type in (''S'',''G'',''U'')
and name not in (''dbo'',''guest'',''sys'',''INFORMATION_SCHEMA'',''##MS_PolicyEventProcessingLogin##'')'
SELECT *
FROM #tmp