Dropping a table with powershell
A cleaner way to do this would be to get the table object from the database object directly, and then drop it if it returns non-null. This will ONLY run if the table exists.

#drop the Table
$tb = $db.Tables['listeningport']
IF ($tb)
    {$tb.Drop()}


You can use $tb.Tables['tablename', 'schemaname'] to use a non-dbo schema.

When I deal with things like this in SMO my preference is ALWAYS to get the child objects from the parent object directly. It's cleaner, it's more obvious to the next person reading the code what you're doing (you're getting the table directly from that table collection in the db object), and it's very easy to check for existence in a single step.

For your specific issue, it's possible that the table is not created with that name since you're looking at tempdb. Are you sure it's there with that specific name?