SMO, Powershell, & Failed Logins
The answer to almost all questions about Powershell/SMO is to use SMOs object model less, and TSQL more.  EG

$dbs = Invoke-Sqlcmd "select name from sys.databases where state_desc = 'ONLINE'" 

foreach ($db in $dbs)
{
  $dbName = $db.Name
  #. . . 
}