Without the entire script it's hard to say where the error originates, but it would be my guess that somewhere else in your script you set the value of the variable $BadOnboarded to be something other than an array.
The error says that it has a type of "System.Management.Automation.PSObject".