Error when trying to save .ma file

Sometimes when trying to save a .ma file from Maya you get this error…

File contains unknown nodes or data. To preserve this information, the current file type cannot be changed.

To fix this you need to remove various unknown elements from the DAG, to do this type the following into the Script Editor.

ls -type unknown;
delete `ls -type unknown`;