I found the problem. The Get-Mailbox on the domain also returned a DiscoverySearchMailbox that must be empty, or atleast return something that is not in a format. So to fix that, I just added a -notlike to get rid of that :)
Well, good thing it happened, otherwise I probably wouldn't have caught it.