This GhPython script sounds like it might work for you:
There’s also one further down that returns the guids as well.