I have a Datastore which is really full, and I need to clean it, I am looking for a powercli script that will clean the datastore and only keep the
VMs that are registered
That is correct if you use for example the Remove-VM cmdlet with the DeletePermanently switch.
If you don't use that switch, the VM will be unregistered and the files on the datastore for that VM, which will not be removed, will represent an orphaned VM.
The script I pointed to earlier finds such orphaned VMs, in other words it finds VMs sitting on the datastore, but not in the inventory.