The 'Database' with 'ID' = 'xxxxxxx' doesn't exist in the collection
One thing that could cause this is if you use the Name of the database instead of the ID.

For example, I created a database with with the name Demo1, so the ID defaulted to the same string.

Afterwards I renamed the database, but that doesn't change the ID. 

If your AMO script uses the name string instead of the ID string that could cause this error.